Python中的字典变量格式';s Mysqldb

Python中的字典变量格式';s Mysqldb,python,formatting,mysql-python,Python,Formatting,Mysql Python,我试图在python 2.7中的mysqldb insert语句中使用dictionary变量: cursor.execute("INSERT INTO DCPOWERSTATS(TS,TOTALPOWER,ITPOWER,AVAILABLEPOWER,PuE) VALUES (%s %s %s %s %s)",(dict_timestamp[key], dict_ABFeeds[key], dict_ABITLOAD[key], 1400, PuE)) 表格如下: sql_createpow

我试图在python 2.7中的mysqldb insert语句中使用dictionary变量:

cursor.execute("INSERT INTO DCPOWERSTATS(TS,TOTALPOWER,ITPOWER,AVAILABLEPOWER,PuE) VALUES (%s %s %s %s %s)",(dict_timestamp[key], dict_ABFeeds[key], dict_ABITLOAD[key], 1400, PuE))
表格如下:

sql_createpowertable = '''CREATE TABLE IF NOT EXISTS DCPOWERSTATS  (TS DATETIME ,TOTALPOWER FLOAT,ITPOWER FLOAT, AVAILABLEPOWER FLOAT, PuE FLOAT)''' 

cursor.execute(sql_createpowertable) .
当我尝试此操作时,会出现以下错误:

_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 '483.9 334.4 1400 1.44706937799043)' at line 1")

insert语句中的每个
%s
后面都需要逗号:

INSERT INTO DCPOWERSTATS(TS,TOTALPOWER,ITPOWER,AVAILABLEPOWER,PuE) VALUES (%s, %s, %s, %s, %s)