1.sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1170, “BLOB/TEXT column ‘teacher’ used in key specification without a key length”)
这个是指你该表单里面的某一column的格式问题,比如这个就是TEXT错误
sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (3780, “Referencing column ‘teacher’ and referenced column ‘username’ in foreign key constraint ‘app_student_ibfk_1’ are incompatible.”)
这个是model.py中建表时使用ForeignKey外键所建的Column的格式时和原引用的Column的格式不同。
2.sqlalchemy.exc.ArgumentError: Mapper mapped class App_student->app_student could not assemble any primary key columns for mapped table ‘app_student’
这个是因为数据表没有主键,假如一个表没有主键,查询就是遍历查询,如果有主键,会以平衡树数据格式去查询.(一个表只能有唯一一个外键,但是一个表中必须有一个及以上的主键)
3.sqlalchemy.exc.InternalError: (pymysql.err.InternalError) (1822, “Failed to add the foreign key constraint. Missing index for constraint ‘app_student_ibfk_1’ in the referenced table ‘user’”)
我这个遇见的问题是因为我的第二张表中设置了两个外键,而数据表中只能有唯一一个外键。