在PyCharm中编写查询时遇到一些问题

这是我的代码:

cursor.execute("SELECT student_email, course_id, section_no FROM LSU.Enrolls")
enroll = cursor.fetchall()
cursor.execute("SELECT course_id, sec_no, team_id FROM LSU.Capstone_Team")
team = cursor.fetchall()
for i in enroll:
    for j in team:
        if i[1] == j[0] and i[2] == j[1]:
            cursor.execute("INSERT IGNORE INTO LSU.Capstone_Team_Members (student_email, team_id, course_id, sec_no) VALUES ('%s', '%s', '%s', '%s')" , (i[0], j[2], i[1], i[2]))


这是我的错误文本:

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 'aan1394@lionstate.edu'', '3', ''CMPSC497'', '1')' at line 1")


有人可以帮我吗?

最佳答案

在上一个查询中,将占位符值的圆括号更改为方括号。另外,请尝试删除占位符周围的引号。

关于mysql - MySQLdb._exceptions.ProgrammingError:(1064,“您的SQL语法有错误),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55623314/

10-12 18:11
查看更多