1
我有SQLAlchemy的沒有經驗,我有以下代碼:使用sqlalchemy時,__table_args__的用途是什麼?
class ForecastBedSetting(Base):
__tablename__ = 'forecast_bed_settings'
__table_args__ = (
Index('idx_forecast_bed_settings_forecast_id_property_id_beds',
'forecast_id', 'property_id',
'beds'),
)
forecast_id = Column(ForeignKey(u'forecasts.id'), nullable=False)
property_id = Column(ForeignKey(u'properties.id'), nullable=False, index=True)
# more definition of columns
雖然我已經檢查this,我不明白是什麼__table_args__
目的,所以我不知道這行是這樣做的:
__table_args__ = (
Index('idx_forecast_bed_settings_forecast_id_property_id_beds',
'forecast_id', 'property_id',
'beds'),
)
可能有人請解釋我是什麼__table_args__
的目的,什麼以前的一段代碼在做什麼。
非常感謝你 – lmiguelvargasf