当前位置:网站首页>Pymysql inserts data into MySQL and reports an error for no reason

Pymysql inserts data into MySQL and reports an error for no reason

2022-06-24 08:45:00 YJ

A strange and magical thing , In the use of pymysql towards MySQL In the process of inserting data , Report the following error ( There is no error in inserting some tables !)

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 ‘- Pay buyers , Number of buyers paid by fans , Buy more goods - Pay buyers , Guide store ’ at line 1”)
 Insert picture description here

The insertion form of the data used is as follows :

insert into  Business Consultant _ Wireless store source data ( date , Source of flow , Source details , Number of visitors , The number of visitors has been compared month on month , Order amount , Change in order amount , Number of buyers to place an order , Change in the number of buyers placing orders , Order conversion rate , Order conversion rate changes , Pay the amount , Change in payment amount , Pay buyers , Change in the number of paying buyers , Payment conversion rate , Payment conversion rate changes , Customer unit price , Change in customer unit price ,UV value ,uv Value change , Pay attention to the number of store buyers , Pay attention to the changes in the number of store buyers , Number of buyers of collection goods , Changes in the number of buyers of collections , Number of additional buyers , Changes in the number of additional buyers , New visitors , New visitor changes , Direct payment to buyers , Collect goods - Pay buyers , Number of buyers paid by fans , Buy more goods - Pay buyers , Number of visitors to the guide store page , Guide the number of visitors to the store page to change ) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)

Wrong guess :
It is estimated that the field is too long, resulting in an exception in the insertion

You can use the second method to insert data

#  The first way 
insert into  Table name ( Field name 1, Field name 2,...) values( value 1, value 2,...);

#  The second way : Insert data according to all fields in the table , It must be consistent with the order in which the fields are defined in the table 
insert into   Table name  values( value 1, value 2,...);
原网站

版权声明
本文为[YJ]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/175/202206240620101304.html