当我试图创建这个表时,我遇到了一个奇怪的错误......当我回溯它时,我在第 5 行什么都没有?谁能帮助我如何跟踪此错误?
导入设置从数据库导入mysql.connector 导入login_info 导入日期时间作为dt
def main():
db = mysql.connector.Connect(**login_info)
cursor = db.cursor()
sql =('DROP TABLE IF EXISTS messages')
cursor.execute(sql)
db.commit()
message_table = """\
CREATE TABLE messages(
msgID INTEGER AUTO_INCREMENT PRIMARY KEY,
message VARCHAR(500) DEFAULT NULL,
subject VARCHAR(500) DEFAULT NULL,
)"""
cursor.execute(message_table)
db.commit()
Error == mysql.connector.errors.ProgrammingError: 1064: 你的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 5 行的 ')' 附近使用正确的语法
我可以在交互式窗口中连接 ot SQl 没问题。