Pymysql did not insert successfully and did not report wrong cursor.execute.

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?

Mar.31,2021

Python 3 string format is not "% s% s"% (1 code 2) . I think a lot of people are done by separating them with commas.
Python3 string formatting cannot be formatted using lists. A list can only format one position

. If you can, I suggest you take a look at the value of cons . I think you have another parenthesis around cons . It has become a tuple. It is recommended to troubleshoot the data to be formatted

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b3ec-2afbf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b3ec-2afbf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?