SQL语法中的Pymsql错误创建表%s

时间:2015-10-09 08:29:08

标签: python mysql syntax-error creation

python脚本中的这个语句给我一个错误

def Create(file0):
         try:                
                     connection = db.connect(host = 'localhost', user = '...', password = '', database ='...')
                     cursor = connection.cursor(db.cursors.DictCursor)
                     cursor.execute("CREATE TABLE %s (filename varchar(255) not null); ", (file0))
         except db.Error as e :
             result  = "DB is in trouble at the moment. Call again later."   
             print ( e )
  

(1064,你“你的SQL语法有错误;请查看手册   对应于您的MySQL服务器版本,以便使用正确的语法   在''tablename'附近(文件名varchar(255)not null)'在第1行“)

print(file 0 )提供没有任何''

的表名

但是当它转到“create statement”时,它会给出额外的引号'tablename'。

如何解决这个问题?

0 个答案:

没有答案