我在使用python这样在mysqldb中创建表时遇到了问题:
cursor.execute("CREATE TABLE IF NOT EXISTS %s ( tweetId VARCHAR(100) NOT NULL, tweet VARCHAR(180) NOT NULL, PRIMARY KEY(tweetId) )",('Tutulive')) .
我收到此错误:
_mysql_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 ''Tutulive' ( tweetId VARCHAR(100) NOT NULL, tweet VARCHAR(180) NOT NULL, PRIMARY' at line 1")
答案 0 :(得分:0)
不应将SQL参数用于元数据。自己清理值并将其正常插入字符串。