Reputation: 609
the index gives an error message
Index('unique-example', example.c.col1, example.c.col2, unique=True)
Why is this the case?
This is my class
class ExampleClass(Base):
__tablename__ = 'example'
__table_args__ = {'sqlite_autoincrement': True}, (Index('unique-example', col1, col2, unique=True))
index = Column(Integer, primary_key= True, nullable=False)
col1 = Column(Integer, nullable=True)
col2 = Column(String, nullable=True)
col3 = Column(String, nullable=True)
What is wrong?
Upvotes: 1
Views: 148
Reputation: 15120
a dictionary with keyword arguments should be the last argument in the __table_args__
, see Table Configuration
__table_args__ = (Index('unique-example', 'col1', 'col2', unique=True)), {'sqlite_autoincrement': True}
Upvotes: 1