|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import pymysql
# 连接数据库
database = pymysql.connect("localhost", "root", "root", "123456", charset='utf8')
# 初始化指针
c = database.cursor()
# # 增删改查
# # 增
sql = "INSERT INTO 111(id, tittle, price, content, call) VALUES ('6666', '1', '11', '111', '1111');"
c.execute(sql)
database.commit()
database.close()
报错的提示如下:
Traceback (most recent call last):
File "D:/python/mysql.py", line 14, in <module>
c.execute(sql)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\cursors.py", line 170, in execute
result = self._query(query)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\cursors.py", line 328, in _query
conn.query(q)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\connections.py", line 517, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\connections.py", line 732, in _read_query_result
result.read()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\connections.py", line 1075, in read
first_packet = self.connection._read_packet()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\connections.py", line 684, in _read_packet
packet.check_error()
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\protocol.py", line 220, in check_error
err.raise_mysql_exception(self._data)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymysql\err.py", line 109, in raise_mysql_exception
raise errorclass(errno, errval)
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 '111(id, tittle, price, content, call) VALUES ('6666', '1', '11', '111', '1111')' at line 1")
Process finished with exit code 1
|
|