- 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

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -