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

1

1 Answer 1

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))
Sign up to request clarification or add additional context in comments.

1 Comment

Wow that worked! In 3 minutes once it unlocks I will mark this as correct. Thanks so much. Its always the small issues...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.