我很难用SQLALchemy为sqlite3数据库中的表创建索引。每次通过celery的定期任务将一行添加到数据库中,该行都将被索引。在
也许我的理解有缺陷。。我认为一旦第一行数据到达数据库,db.Index('scheduleId', Schedule.taskId)
会自动创建一个值为1的新的“scheduleId”列?在
应用程序/模型.py
class Schedule(db.Model):
__tablename__ = 'schedule'
taskId = db.Column(db.String(50), primary_key=True)
def __init__(self, **kwargs):
super(Schedule, self).__init__(**kwargs)
db.Index('scheduleId', Schedule.taskId)
应用程序/任务/测试.py
^{pr2}$当定期任务运行时,我得到以下错误:
AttributeError: type object 'Schedule' has no attribute 'scheduleId'
修改类模型
Autoincrement Docs
Index Docs
相关问题 更多 >
编程相关推荐