flask错误集锦

版权声明:转载请注明来处 https://blog.csdn.net/Daisy_zye/article/details/85311209

TypeError: The view function did not return a valid response. The function either returned None or ended without a return statement.

视图函数中,没有返回值或返回值缩进不正确。

sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column 'AdminLog.user_id' could not find table 'admin' with which to generate a foreign key to target column 'id'

场景:外键关联,迁移数据库时。

解决方案:将原本Admin类中的__tablename__='Admin',改为__tablename__='admin'

sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1050, "Table 'movies' already exists") [SQL: '\nCREATE TABLE `Movies` (\n\tid INTEGER
 NOT NULL AUTO_INCREMENT, \n\ttitle VARCHAR(50), \n\tadd_time DATETIME, \n\ttag_id INTEGER, \n\turl VARCHAR(255), \n\tinfo TEXT, \n\tlogo VARCHA
R(255), \n\tarea VARCHAR(50), \n\tlength INTEGER, \n\trelease_time DATE, \n\tstar SMALLINT, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(tag_id) REFERE
NCES tag (id), \n\tUNIQUE (logo), \n\tUNIQUE (title), \n\tUNIQUE (url)\n)\n\n']

数据库中已存在movies表。(很奇怪为什么migrate的时候还会生成movies的脚本……)将迁移记录删除,重新迁移。

猜你喜欢

转载自blog.csdn.net/Daisy_zye/article/details/85311209