Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL/Python创建表错误_Python_Mysql_Sql - Fatal编程技术网

SQL/Python创建表错误

SQL/Python创建表错误,python,mysql,sql,Python,Mysql,Sql,当我试图创建此表时,出现了一个奇怪的错误。。。。当我追溯到第五行时,我什么都没有?有人能帮我追踪这个错误吗 导入设置 导入mysql.connector 从数据库导入登录信息 将日期时间导入为dt def main(): db = mysql.connector.Connect(**login_info) cursor = db.cursor() sql =('DROP TABLE IF EXISTS messages') cursor.execute(sql)

当我试图创建此表时,出现了一个奇怪的错误。。。。当我追溯到第五行时,我什么都没有?有人能帮我追踪这个错误吗

导入设置 导入mysql.connector 从数据库导入登录信息 将日期时间导入为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()
错误== mysql.connector.errors.ProgrammingError:1064:您的SQL语法有错误;检查与MySQL服务器版本相对应的手册,以了解第5行中使用“')”附近的正确语法


我可以在交互式窗口中连接ot SQl,没有问题。

尝试删除第4行末尾的

在最后一个空值之后。我认为您不允许在最后一个字段声明之后有一个尾随的
。由于圆括号('DROP TABLE IF EXISTS messages')语法错误,在您当前遇到的问题之后,您可能会有进一步的问题:最后一个字段定义后面的逗号。逗号用于分隔表定义的元素(字段、索引等)。。。请始终记住检查文档(在本例中为MySQL文档:数据定义语句:CREATE)。错误消息甚至可以很好地提示错误的位置。