1

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

triunenature
  • 651
  • 2
  • 7
  • 23

1 Answers1

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))
mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
  • Wow that worked! In 3 minutes once it unlocks I will mark this as correct. Thanks so much. Its always the small issues... – triunenature Sep 13 '13 at 22:46