Reputation: 685
I can't insert data into sqlite table. Here is my code:
import sqlite3
connection = sqlite3.connect('mydata.db')
cursor = connection.cursor()
a=raw_input('name')
a=str(a)
b=raw_input('theme')
b=str(b)
c=raw_input('language')
c=str(c)
sql="INSERT INTO Website (Website, Theme, Language) VALUES (%, %, %)",(a,b,c)
cursor.execute(sql)
connection.commit()
connection.close()
For some reason it doesn't work.
Upvotes: 0
Views: 4717
Reputation: 414129
the extended call syntax is f(*args)
:
cursor.execute(*sql)
sqlite uses '?'
placeholder:
conn.execute('insert into sometable values (?,?,?)', (a,b,c))
raw_input()
already returns a string. a = str(a)
is unnecessaryUpvotes: 1