• sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (1146, "Table 'xxx.authority' doesn't exist")


    • 操作

      • 我是在写项目中把全部的表都删了, 然后进行新建
      if __name__ == '__main__':
          db.create_all()
      
      
    • 报错内容

      The above exception was the direct cause of the following exception:
      
      Traceback (most recent call last):
           省略...............
      File "XXXappadminforms.py", line 10, in <module>
          authority_list = [(v.id, v.name) for v in Authority.query.all()]
           省略...............
      sqlalchemy.exc.ProgrammingError: (_mysql_exceptions.ProgrammingError) (1146, "Table 'xxx.authority' doesn't exist") [SQL: 'SELECT authority.id AS authority_id, authority.name AS authority_name, authority.url AS authority_url, authority.add_time AS authority_add_time 
      FROM authority'] (Background on this error at: http://sqlalche.me/e/f405)
      
      Process finished with exit code 1
      
    • 分析

      • 我们可以从上述内容中知道他是,表不存在,然而他却在forms.py先进行查询, emmmmmmm
    • 解决方法

      • 在forms.py中先将查询部分注释, 执行完db.creat_all()后,再去掉注释
      authority_list = []
      #authority_list = [(v.id, v.name) for v in Authority.query.all()]
      
  • 相关阅读:
    Jquery 获取CheckBoxList 中选择的值和获取RadioButton 选中的状态
    JS数组取相同的值和不同的值
    JS删除数组总是报错
    调用WebAPI接口
    MVC3 Excel导入数据到sql Server数据库
    MVC JS动态添加 @Html.DropDownList
    得瑟一下
    出差小记
    jQuery自学打卡二
    jQuery自学打卡一
  • 原文地址:https://www.cnblogs.com/edhg/p/8931845.html
Copyright © 2020-2023  润新知