gpt4 book ai didi

python - 1064, "You have an error in your SQL syntax"插入(另一个)

转载 作者:行者123 更新时间:2023-11-29 16:08:44 33 4
gpt4 key购买 nike

我的 IDE 出现以下错误:

MySQLdb._exceptions.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 '2102@lionstate.edu', '88zlsj5j', 'Kristopher O'Connell', '21', 'F', 'CMPSC', '77' at line 1")

这是我的代码中导致错误的部分:

for a, b, c, d, e ,f, g, h in zip(df_stu['Email'], df_stu['Password'], df_stu['Full Name'], df_stu['Age'], df_stu['Gender'], df_stu['Major'], df_stu['Street'], df_stu['Zip']):
cursor.execute("INSERT INTO LSU.Student (Semail, Spassword, Sname, Sage, Sgender, Smajor, Sstreet, Szipcode) "
"VALUES ('%s', '%s', '%s', '%d', '%s', '%s', '%s', '%d')" % (a, b, c, d, e, f, g, h))

这是我的创建表:

cursor.execute("CREATE TABLE IF NOT EXISTS LSU.Student (Semail CHAR(50), Spassword CHAR(20), Sname CHAR(50), "
"Sage INT, Sgender CHAR(5), Smajor CHAR(50), Sstreet CHAR(50), Szipcode INT, PRIMARY KEY (Semail))")

这对我来说看起来是正确的,但 IDE 一直说存在语法错误。

最佳答案

“Kristopher O'Connell”中的单引号 (') 会干扰查询吗?

关于python - 1064, "You have an error in your SQL syntax"插入(另一个),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55486067/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com