I want to add some data from variables into my database using sqlite library in python. I create a table and then run the sql statement. Here is my simple code:
import sqlite3
db = sqlite3.connect("dbse.sqlite")
cursor= db.cursor()
cursor.execute("CREATE TABLE Myt (Test TEXT)")
variable = ('aaa')
cursor.execute('INSERT INTO Myt VALUES (?)' , variable)
db.commit()
but after running the code, this error comes up:
cursor.execute('INSERT INTO Myt VALUES (?)' , variable)
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 1, and there are 3 supplied.
When I insert a variable that contains a one character value, it works well but when I use a variable with more than one character, it doesn't work. I use python 3.2.3 . Do you have an idea to solve it?