sqlite3 using python module deletes the data error parameters are of unsupported type

import sqlite3
# Link Database
con = sqlite3.connect('C:\python_learn\DBA\SQLite3demo\sqlite3demo.db')
# Create a cursor object
cur = con.cursor()
# Write sql statement
sql = "delete from t_person where pno = ?"
# Sql execution
try:
    cur.execute(sql,(1))
    con.commit ()
    print ( "deleted successfully")
except Exception as e:
    print (e)
    print ( "Delete failed")
    con.rollback()
finally:
    # Close the connection
    # Close the cursor
    cur.close()
    con.close()

Deleted data is a tuple type, and therefore should be followed by a comma 1, modified cur.execute (sql, (1,), can be performed successfully;

Published 14 original articles · won praise 0 · Views 153

Guess you like

Origin blog.csdn.net/yimaoyingbi/article/details/104323701