So I am trying to get a simple program to insert information into a sqlite db.
The line that is breaking is the cur.execute
sitename = "TEST sitename2"
siteusername = "TEST siteusername2"
sitepasswd = "TEST sitepassword2"
cur.execute("INSERT INTO mytable(sitename, siteusername, sitepasswd) VALUES(%s, %s, %s)", (sitename, siteusername, sitepasswd))
Error that I receive from Python:
sqlite3.OperationalError: near "%": syntax error
asked Sep 13, 2013 at 22:35
triunenature
6712 gold badges7 silver badges24 bronze badges
-
Pastebin for complete code: pastebin.com/GF12ty6gtriunenature– triunenature2013年09月13日 22:38:47 +00:00Commented Sep 13, 2013 at 22:38
1 Answer 1
You simply have the wrong parameter style.
>>> import sqlite3
>>> sqlite3.paramstyle
'qmark'
Change your code to:
cur.execute("""INSERT INTO mytable(sitename, siteusername, sitepasswd)
VALUES (?, ?, ?)""", (sitename, siteusername, sitepasswd))
answered Sep 13, 2013 at 22:44
mechanical_meat
170k25 gold badges238 silver badges231 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
triunenature
Wow that worked! In 3 minutes once it unlocks I will mark this as correct. Thanks so much. Its always the small issues...
default