Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8501511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:13:57+00:00 2026-06-11T01:13:57+00:00

In declarative approach, I want to exclude one property, its working properly when my

  • 0

In declarative approach, I want to exclude one property, its working properly when my column name and property name are same. But if I give different name then its not working.
Here is my sample code.

Base = declarative_base() 
class tblUser(Base):
    __tablename__ = 'tblUser'
    User_Id = Column('User_Id', String(100), primary_key=True)
    SequenceNo = Column('Sequence_No', Integer)
    FullName = Column('FullName', String(50))
    __mapper_args__ = {'exclude_properties' :['Sequence_No']}

user = tblUser()
user.User_Id = '1000001'
user.SequenceNo = 101
session.add(user)
session.commit()

In the above sample I don’t want the SequenceNo property to be updated in database even if I assign some value to it. So I used exclude_properties but still its updating the value in db. But if I change the property name from SequenceNo to Sequence_No (same as the column name) then its working as per the behaviour. Can anyone help me?

Thanks
Adhi

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:13:59+00:00Added an answer on June 11, 2026 at 1:13 am

    Unfortunately, __mapper_args__ is probably the wrong approach. It is intended to control the reflection of an existing database table into a mapper, not make a column ‘read-only’.

    I think a better approach would be to use a hybrid property:

    from sqlalchemy.ext.hybrid import hybrid_property
    
    Base = declarative_base() 
    class tblUser(Base):
        __tablename__ = 'tblUser'
        User_Id = Column('User_Id', String(100), primary_key=True)
        FullName = Column('FullName', String(50))
    
        _Sequence_No = Column('Sequence_No', Integer)
        _local_Sequence_No = None
    
        @hybrid_property
        @property
        def SequenceNo(self):
            if self._local_Sequence_No is not None:
                return self._local_Sequence_No
            return self._SequenceNo
    
        @SequenceNo.setter
        def SequenceNo(self, value):
            self._local_Sequence_No = value
    

    The original Sequence_No column is available via a private attribute, and the SequenceNo property intercepts writes and stores them on the instance to be re-used later, but not written to the database.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand what declarative languages have to offer, but I have not yet connected
Models from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, ForeignKey from sqlalchemy import Integer
While creating DOJO Components when should we prefer declarative approach and programatic approach?
I am using annotation based declarative approach for spring aop. sample code ClassA{ @Transactional(readOnly
I just liked the declarative approach of jQuery Mobile! It is a good option
Firstly, I can't use the declarative @Transactional approach as the application has multiple JDBC
I'm fairly new to C but writing a small multithreaded application. I want to
I want to create a property in a category so I can use dot
Can you recommend a declarative table-generation taglib for JSP (with EL) that is still
I am extensively using declarative dojo DataStores in my application and connecting them to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.