1064 错误,使用蟒蛇操作 MySQL 数据库

我想在Python中编写一个程序来控制MySQL数据库,但发生以下错误


pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; chec

k the manual that corresponds to your MySQL server version for the right syntax

to use near 'Code,type, number,Whether )VALUES ('cl8k-k520-fg45-d4sa-sd9k','n' at line 1")

法典:


import pymysql 

db = pymysql.connect("localhost", "root", "root", "test")

cursor = db.cursor()

sql = "INSERT INTO BOOKS(Activation Code, \

       type, number,Whether ) \

       VALUES (%s,%s,%s,%s)"

data = [("cl8k-k520-fg45-d4sa-sd9k",'n','10','n'),

        ("jhg6-58jh-gh8o-8uik-7jk8",'c','20','n'),

        ("x5hg-gf5h-4hj5-g4h5-fh5t",'y','999','n'),

        ("fg8j-h584-fd4g-fg4d-fgg4",'n','1','y'),

        ("4jk4-5kl4-4klk-4lji-4ghj",'e','6','n'),

        ]

cursor.executemany(sql,data)

db.close()

这是我第一次在这个平台上提问。我希望得到答案


明月笑刀无情
浏览 138回答 1
1回答

猛跑小猪

封闭为Activation Code'Activation Code'
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python