我已经在各种配置中对抗此错误几天了。 我尝试在每个ForeignKeys下添加关系线而没有运气。 我还将查询从使用declarative_base样式调用交换到SQL查询。 只有在我将第二个ForeignKey添加到Task时才会出现错误。 (我最初在Task和Project中有几个外键,但是直到它起作用并且尝试慢慢添加东西。添加第二个ForeignKey无论添加到哪个表都做了。)
我目前的Flask方法是:
it/specify
我得到一个"没有这样的专栏"错误:
@app.route('/project/<int:project_id>/')
def showProject(project_id):
project = session.query(Project).from_statement(text("SELECT * FROM project WHERE project.id = project_id ORDER BY project.projnum DESC"))
tasks = session.query(Task).filter_by(project_id = project_id).all()
return render_template('project.html', project = project, tasks = tasks)
这是我的数据库的安装文件:
OperationalError: (sqlite3.OperationalError) no such column: task.project_id [SQL: u'SELECT task.id AS task_id, task.name AS task_name, task.description AS task_description, task.assigned_id AS task_assigned_id, task.project_id AS task_project_id, task.due AS task_due \nFROM task \nWHERE task.project_id = ?'] [parameters: (2,)]
在阅读了大量文档并疯狂地尝试随机操作之后,我很感激任何建议!