On 6/2/15 12:05 PM, Richard Gerd Kuesters wrote:
oh, sorry Mike, I forgot to mention that I use TimestampMixin in other
classes aswell, so I got an "existent index error" (something like
that). Is there a way I don't need to declare the index name? (IMHO
this appears to be the problem).
indexes have to be named something so you'd have to figure out a naming
convention based on tables/column names. There should be an existing
convention for indexes so if you set "None" as the name it should make
one up for you like "ix_tablename_columnname"
thanks a lot!
richard.
On 06/02/2015 12:28 PM, Mike Bayer wrote:
On 6/2/15 10:16 AM, Richard Gerd Kuesters wrote:
hi all, again :)
how can I create an index in fields inherited by other classes?
example:
class TimestampMixin(object):
updated_on = Column(DateTime) # i wanted to create three
indexes in this field, "updated_on", "updated_on.asc()" and
"updated_on.desc()"
class SomeOtherClass(Base, TimestampMixin):
__tablename__ = 'some_table'
id = Column(Integer)
....
Index('ix_some_other_class_01', SomeOtherClass.updated_on)
Index('ix_some_other_class_02', SomeOtherClass.updated_on.asc())
Index('ix_some_other_class_03', SomeOtherClass.updated_on.desc())
I just want to avoid repetition, if possible :)
you could use a __table_args__() callable with @declared_attr. Or use
a mapping event like __declare_first__() or __declare_last__() (these
are hooked into the before_configured / after_configured events which
you could also use directly, e.g.
http://docs.sqlalchemy.org/en/rel_1_0/orm/events.html?highlight=before_configure#sqlalchemy.orm.events.MapperEvents.before_configured)
best regards,
richard.
--
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 sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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 sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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 sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.