pymysql.err.ProgrammingError: (1064, “You have an error in your SQL syntax; check the manual that co

问题描述:

Django数据管理((python/mysql))-yaml封装初始化数据

python运行mysql_action.py脚本时报错:pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'groups) values('1','Sharon','[email protected]','http://127.0.0.1:8000/groups/1/')' at line 1")

原因解析:

mysql_action.py脚本中导入的初始化数据datas.yaml文件里的groups与MySQL的关键词冲突,导致执行insert语句报错。

解决方案:

把datas_yaml文件里面的groups字段改成:api_user.groups(即“表名.字段名”)即可解决关键字冲突问题。

 

 

 

你可能感兴趣的:(Python报错,mysql报错,python,mysql,封装)