欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server

程序员文章站 2022-07-14 10:29:02
...

完整的语法错误是这样的:
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 ‘)’ at line 10”)

原代码

import pymysql

db = pymysql.connect("localhost",'root','700719trying','DOUBANMOVIE')

cursor = db.cursor()

cursor.execute("DROP TABLE IF EXISTS MOVIE")

sql = """CREATE TABLE MOVIE(
    id INT NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT '自增 id',
    name1 VARCHAR(1024),
    rank BIGINT(4),
    info VARCHAR(1024),
    rating FLOAT,
    num BIGINT(4),
    quote VARCHAR(1024),
    img_url VARCHAR(1024),
)
"""

cursor.execute(sql)
db.close()

错误原因:粗心
在创建最后一个变量时,后面多加了一个「,」

细心细心,弄清楚最基本的语法规则