flask 学习错误总结 (sqlite3.OperationalError) no such table / no such column

在学习Flask时遇到sqlite3.OperationalError错误,原因是数据库表格缺失。解决方案包括检查数据库配置,确保运行迁移命令更新数据库结构。在项目开始时,使用`python db create`、`python db migrate`、`python db upgrade`。当数据库更改后,需运行`python db migrate`和`python db upgrade`进行更新。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在学习flask狗书的时候在第七章的时候将hello.py分解成为程序结构的时候  出现这个

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: users [SQL: 'SELECT users.id AS users_id, users.username AS users_username, users.role_id AS users_role_id \nFROM users \nWHERE users.username = ?\n LIMIT ? OFFSET ?']


在谷歌了很久以后发现了 作者的回答 you probably missed the fact that after the restructure in chapter 7 the name of the database has changed. Post chapter 7 the application has multiple configurations, and each configuration uses a different database. So you are probably using an empty database that has no tables. If you run manage.py db upgrade you s

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值