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

完整的语法错误是这样的:
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()

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

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

你可能感兴趣的:(python,问题修正)