SQLAlchemy: Does Column with ForeignKey perform an automatic index?

Does Column create an index with ForeignKey automatically? Or do I need to do this manually by adding index=True ?

 some_field = Column(Integer, ForeignKey(SomeModel.id)) 

Thanks!

+7
source share
1 answer

You need to either specify index=True or explicitly create an Index object:
Index('myindex', mytable.c.col1, mytable.c.col2, unique=True) , which allows more control over other index parameters, such as name and support for multiple columns.

See Indexes for more details.

+12
source

All Articles