Use options for .execute() :
query = """ INSERT INTO credit (bank, number, card, int1, value, type, int2) VALUES (?, ?, ?, ?, ?, ?, ?) """ data = ['Citi', '5567', 'visa', 6000, 9.99, '23', 9000] cursor.execute(query, data)
According to PEP249 :
.execute(operation[,parameters])
Prepare and execute the database operation (query or command). Parameters can be represented as a sequence or mapping and will be bound to variables in the operation. Variables are specified in the database notation (for more details see the paramstyle attribute)
Check paramstyle :
>>> import sqlite3 >>> print sqlite3.paramstyle qmark
qmark means what are you using ? for parameters.
source share