python - Why am I getting SQLAlchemy Error "__table_args__ value must be a tuple, dict, or None" -


i have following sqlalchemy model. has been migrated database:

class myclassa(db.model, timestamp):     a_id = db.column(db.integer, nullable=false, primary_key=true)     b_id = db.column(db.integer, db.foreignkey(c.c_id), nullable=false)     d = db.column(db.string(1024))     e_id = db.column(db.integer,                       db.foreignkey(e.e_id)) 

now want add uniqueness constraint across second , fourth fields. add following line model:

     __table_args__ = db.uniqueconstraint('b_id', 'e_id', name='unique_constraint_bid_eid') 

but when try migrate it, following error:

sqlalchemy.exc.argumenterror: __table_args__ value must tuple, dict, or none 

why getting error? , how can fix it? tried putting right side of equation in parenthesis, didn't fix it.

table_args supposed tuple, dict, or none error code suggests. if make tuple must put value in parenthesis , have comma in there @ end:

try:

     __table_args__ = (db.uniqueconstraint('b_id', 'e_id', name='unique_constraint_bid_eid'), ) 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -