def save_db(cons):
db = pymysql.connect(host = "127.0.0.1" , user = "root" , password = "root" , port = 3306)
cursor = db.cursor()
sql = "INSERT INTO quote(jy_time,open_price,high_price,low_price,over_price,zhangdiee,zhangdief,chengjiaol,chengjiaoj,zhenfu,huanshoul) VALUE (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
print("...")
try:
cursor.execute(sql,(cons))
print(cons)
db.commit()
except:
print("")
db.rollback()
db.close()
Code as above, cursor.execute (sql, (cons))
is the execution failed? execution result:
D:\ProgramData\************\python.exe E:/*******/project/test/test.py
...
...
...
obviously try failed, and then print ("failed")
the exception recaptured is: not all arguments converted during string formatting
is it because I inserted a list instead of a string?