I want to override the default value of a column in the table A, where B is
a child of A.

On Fri, Jun 29, 2018 at 4:29 PM, Mike Bayer <[email protected]>
wrote:

> On Fri, Jun 29, 2018 at 4:20 PM, Marcus Mann <[email protected]> wrote:
> > And why do you use the doc property in
> > data = column_property(A.data, doc="B's data")
> > and why do you change A.data in class B?
>
> well you said you wanted a "description", which I am still unclear
> what you mean by that, "doc" is used to assign a docstring to a column
> attribute.   It places it in __doc__ and shows up in Sphinx
> doumentation, for example.    Then you said you wanted to override it
> on B so I re-wrapped it.
>
> I'm not sure that's what you want now, your example looks more like
> you want the value of the attribute to be fixed on the subclass, but
> persisted on the superclass?  i don't see how that would work yet.
>
>
> >
> > On Fri, Jun 29, 2018 at 4:18 PM, Mike Bayer <[email protected]>
> > wrote:
> >>
> >> a Column is a Core schema construct that is not part of the ORM.   The
> >> ORM maps a Column to your mapped class using a column_property() that
> >> wraps around it.  When you use declarative_base, the declarative
> >> system is automatically generating these column_property() objects for
> >> each Column you have by itself.
> >>
> >> On Fri, Jun 29, 2018 at 4:16 PM, Marcus Mann <[email protected]>
> wrote:
> >> > I guess I am still a little confused about the relationship between
> >> > Column
> >> > and column_property
> >> >
> >> > On Fri, Jun 29, 2018 at 4:14 PM, Mike Bayer <[email protected]
> >
> >> > wrote:
> >> >>
> >> >> On Fri, Jun 29, 2018 at 11:46 AM, Marcus Mann <[email protected]>
> >> >> wrote:
> >> >> > When I said description, I just meant a simple string that
> describes
> >> >> > the
> >> >> > object, not a python docstring. Just an example column.
> >> >>
> >> >> so....does my example answer your question?
> >> >>
> >> >>
> >> >>
> >> >>
> >> >> >
> >> >> > On Friday, June 29, 2018 at 9:49:07 AM UTC-4, Mike Bayer wrote:
> >> >> >>
> >> >> >> your question is getting no answers because it is vague and
> doesn't
> >> >> >> provide any code.   what's a "description"?   you mean a Python
> >> >> >> docstring ?   Python attributes don't have a __doc__ normally, if
> >> >> >> you
> >> >> >> mean the "doc" parameter, just make a separate property:
> >> >> >>
> >> >> >> class A(Base):
> >> >> >>     __tablename__ = 'a'
> >> >> >>
> >> >> >>     id = Column(Integer, primary_key=True)
> >> >> >>
> >> >> >>     data = column_property(Column(String), doc="the data")
> >> >> >>
> >> >> >>
> >> >> >> class B(A):
> >> >> >>     __tablename__ = 'b'
> >> >> >>
> >> >> >>     id = Column(ForeignKey('a.id'), primary_key=True)
> >> >> >>
> >> >> >>     data = column_property(A.data, doc="B's data")
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >> On Fri, Jun 29, 2018 at 8:41 AM, Marcus Mann <[email protected]>
> >> >> >> wrote:
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > https://stackoverflow.com/questions/51046900/how-to-
> access-override-defaults-on-parents-attribute-in-sql-alchemy
> >> >> >> >
> >> >> >> > --
> >> >> >> > SQLAlchemy -
> >> >> >> > The Python SQL Toolkit and Object Relational Mapper
> >> >> >> >
> >> >> >> > http://www.sqlalchemy.org/
> >> >> >> >
> >> >> >> > To post example code, please provide an MCVE: Minimal, Complete,
> >> >> >> > and
> >> >> >> > Verifiable Example. See http://stackoverflow.com/help/mcve for
> a
> >> >> >> > full
> >> >> >> > description.
> >> >> >> > ---
> >> >> >> > You received this message because you are subscribed to the
> Google
> >> >> >> > Groups
> >> >> >> > "sqlalchemy" group.
> >> >> >> > To unsubscribe from this group and stop receiving emails from
> it,
> >> >> >> > send
> >> >> >> > an
> >> >> >> > email to [email protected].
> >> >> >> > To post to this group, send email to [email protected].
> >> >> >> > Visit this group at https://groups.google.com/group/sqlalchemy.
> >> >> >> > For more options, visit https://groups.google.com/d/optout.
> >> >> >
> >> >> > --
> >> >> > SQLAlchemy -
> >> >> > The Python SQL Toolkit and Object Relational Mapper
> >> >> >
> >> >> > http://www.sqlalchemy.org/
> >> >> >
> >> >> > To post example code, please provide an MCVE: Minimal, Complete,
> and
> >> >> > Verifiable Example. See http://stackoverflow.com/help/mcve for a
> full
> >> >> > description.
> >> >> > ---
> >> >> > You received this message because you are subscribed to the Google
> >> >> > Groups
> >> >> > "sqlalchemy" group.
> >> >> > To unsubscribe from this group and stop receiving emails from it,
> >> >> > send
> >> >> > an
> >> >> > email to [email protected].
> >> >> > To post to this group, send email to [email protected].
> >> >> > Visit this group at https://groups.google.com/group/sqlalchemy.
> >> >> > For more options, visit https://groups.google.com/d/optout.
> >> >>
> >> >> --
> >> >> SQLAlchemy -
> >> >> The Python SQL Toolkit and Object Relational Mapper
> >> >>
> >> >> http://www.sqlalchemy.org/
> >> >>
> >> >> To post example code, please provide an MCVE: Minimal, Complete, and
> >> >> Verifiable Example.  See  http://stackoverflow.com/help/mcve for a
> full
> >> >> description.
> >> >> ---
> >> >> You received this message because you are subscribed to the Google
> >> >> Groups
> >> >> "sqlalchemy" group.
> >> >> To unsubscribe from this group and stop receiving emails from it,
> send
> >> >> an
> >> >> email to [email protected].
> >> >> To post to this group, send email to [email protected].
> >> >> Visit this group at https://groups.google.com/group/sqlalchemy.
> >> >> For more options, visit https://groups.google.com/d/optout.
> >> >
> >> >
> >> > --
> >> > SQLAlchemy -
> >> > The Python SQL Toolkit and Object Relational Mapper
> >> >
> >> > http://www.sqlalchemy.org/
> >> >
> >> > To post example code, please provide an MCVE: Minimal, Complete, and
> >> > Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> >> > description.
> >> > ---
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "sqlalchemy" group.
> >> > To unsubscribe from this group and stop receiving emails from it, send
> >> > an
> >> > email to [email protected].
> >> > To post to this group, send email to [email protected].
> >> > Visit this group at https://groups.google.com/group/sqlalchemy.
> >> > For more options, visit https://groups.google.com/d/optout.
> >>
> >> --
> >> SQLAlchemy -
> >> The Python SQL Toolkit and Object Relational Mapper
> >>
> >> http://www.sqlalchemy.org/
> >>
> >> To post example code, please provide an MCVE: Minimal, Complete, and
> >> Verifiable Example.  See  http://stackoverflow.com/help/mcve for a full
> >> description.
> >> ---
> >> You received this message because you are subscribed to the Google
> Groups
> >> "sqlalchemy" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to [email protected].
> >> To post to this group, send email to [email protected].
> >> Visit this group at https://groups.google.com/group/sqlalchemy.
> >> For more options, visit https://groups.google.com/d/optout.
> >
> >
> > --
> > SQLAlchemy -
> > The Python SQL Toolkit and Object Relational Mapper
> >
> > http://www.sqlalchemy.org/
> >
> > To post example code, please provide an MCVE: Minimal, Complete, and
> > Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> > description.
> > ---
> > You received this message because you are subscribed to the Google Groups
> > "sqlalchemy" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to [email protected].
> > To post to this group, send email to [email protected].
> > Visit this group at https://groups.google.com/group/sqlalchemy.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example.  See  http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to