flask 学习错误总结 (sqlite3.OperationalError) no such table / no such column
2017-10-21 10:12
633 查看
在学习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
然后运行了此步骤过后 程序正常
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: users.confirmed [SQL: 'SELECT users.id AS users_id, users.email AS users_email, users.username AS users_username, users.role_id
AS users_role_id, users.password_hash AS users_password_hash, users.confirmed AS users_confirmed \nFROM users \nWHERE users.email = ?\n LIMIT ? OFFSET ?'] [parameters: ('john@example.com', 1, 0)]
出现此错误是因为在修改了数据库的数据后没有使用 .py db migrate 根据作者的回答可以很清晰的看出每次该怎么做
It goes like this:
When you begin your project, use
When you make changes to your database, use
When you install your code on a new machine, or need to recreate the database from scratch, use
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 upgradeyou should get the tables added to your database. 确实是因为忘记了红色标记的这一步骤
然后运行了此步骤过后 程序正常
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: users.confirmed [SQL: 'SELECT users.id AS users_id, users.email AS users_email, users.username AS users_username, users.role_id
AS users_role_id, users.password_hash AS users_password_hash, users.confirmed AS users_confirmed \nFROM users \nWHERE users.email = ?\n LIMIT ? OFFSET ?'] [parameters: ('john@example.com', 1, 0)]
出现此错误是因为在修改了数据库的数据后没有使用 .py db migrate 根据作者的回答可以很清晰的看出每次该怎么做
It goes like this:
When you begin your project, use
db init, followed by
db migrate, followed by
db upgrade.
When you make changes to your database, use
db migrate, followed by
db upgrade.
When you install your code on a new machine, or need to recreate the database from scratch, use
db upgrade.
相关文章推荐
- 关于“SqliteException: SQLite error no such column: ”错误
- java使用Sqlite 出现类似java.sql.SQLException: no such table: employee错误
- Django错误------django.db.utils.OperationalError: no such table
- sqlite 报 no such table 错误
- Android—Greendao:SQLite Exception: no such table Error [duplicate]
- SQLite3 执行sqlite3_prepare_v2的时候提示“Error:no such table: bookCollect”的原因解析
- SQLite error,no such table的处理方法
- Android之eclipse错误 error opening trace file: No such file or directory (2)解决办法总结
- sqlite 报 no such table 错误
- asp.net sqlite error no such table的解决方案
- 使用flask-ASQLchemy时,Error:No such table
- flask/sqlalchemy - OperationalError: (sqlite3.OperationalError) no such table
- sqlite 报 no such table 错误
- java.lang.NoSuchFieldError: EMPTY_LIST,EMPTY_MAP错误的解决方法
- 错误:error libGL.so: cannot open shared object file: No such file or directory
- Xcode 错误- Could not launch app - No such file or directory Error
- [Python-*-Django]DatabaseError: no such table: blog_blogpost错误
- ERROR hive.ql.metadata.Hive - NoSuchObjectException(message:default.hive_born table not found)
- android.database.sqlite.SQLiteException: table has no column XXX (code 1)问题解决方法
- Android开发遇到error opening trace file: No such file or directory (2) 错误