- Where Developers Learn, Share, & Build Careers


In SQLAlchemy, I want to define a mixer which automatically creates an indicator in getting the tables.

Assuming that there is a member list in the inheriting table called 'keys', I want the mixer to create a single multi-column index in the inherited table on the columns listed in the keys. However, the mixer does not know how long the keys have been made!

How do I do this?

"Text">

example:

 metadata () base = declarative_base (metadata = metadata) class MyMixin (object): @declared_attr def __table_args __ (CLS): return (index ('test_idx_% s '% Cls .__ tablename__, * cls.INDEX), class MyModel (MyMixin, base): __tablename__ =' atable 'INDEX = (' a ',' b ',) id = column (integer, primary_key = true) = Column (integer) B = column (integer) c = column (W Digit) if __name__ == '__main__': sqlalchemy import: create_engine engine = create_engine ('sqlite: ///', echo = true) metadata.bind = engine metadata.create_all ()   < P> Docs:   

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -