def run_create(): '''生成表''' sync_db.connect() # sync_db.create_tables([UserProfile]) # 注意:如果检查没问题后数据库仍然报 (1215, 'Cannot add foreign key constraint') 那么需要使用下面的方式创建表,具体报错原因未知,可能create_tables内执行顺序不一致 # UserProfile.create_table() Group.create_table() Auth.create_table() AuthPermission.create_table() User.create_table() sync_db.close()