將SQLAlchemy和Python與PostgreSQL配合使用作爲數據庫。我有一個表有超過32列,我收到以下錯誤:PostgreSQL錯誤:在索引中不能使用多於32列
cannot use more than 32 columns in an index
下面是我如何創建表的代碼片段:
class Application():
__tablename__ = 'application'
id = Column(Integer, primary_key=True)
name = Column(String)
value = Column(Integer)
# ..and many other columns (45 columns in total)
_columns = ['name', 'value'...] # a list of 45 column names
__table_args__ = (UniqueConstraint(*_columns),)
好像有一個構建選項PostgreSQL的增加的列數多於32: http://www.postgresql.org/docs/8.3/static/indexes-multicolumn.html 從上面的鏈接:
This limit can be altered when building PostgreSQL; see the file pg_config_manual.h
但不知道是否在通過SQLAlchemy API創建表時,有一種方法可以將索引限制爲少於32列。我真的不喜歡爲此重建PostgreSQL數據庫。
你如何定義你的表格? (粘貼一些代碼!)我不認爲它會跑出去,並創建像這樣的大量索引。 –
我認爲它可能是使用所有列作爲索引的UniqueConstraint類! – kaush