0
testid = 69
query = """SELECT * FROM basic_info WHERE ownerid=%s"""
cur.execute(query, testid)
print cur.fetchone()

I am getting an integer error when attempting this. I have tried converting testid to a string with no luck.

0

2 Answers 2

0

I prefer this method of inserting parameters since it's very clear:

query = "SELECT * FROM basic_info WHERE ownerid = %(testid)s"
cur.execute(query, params = { 'testid': testid })
Sign up to request clarification or add additional context in comments.

Comments

0

The second paraemter of Cursor.execute should be a sequence (tuple or list) or a mapping (dict):

testid = 69
query = """SELECT * FROM basic_info WHERE ownerid=%s"""
cur.execute(query, [testid])  # <--
print cur.fetchone()

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.