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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Ben Gitter
  • 31
  • 1

2 Answers2

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 })
gr1zzly be4r
  • 2,072
  • 1
  • 18
  • 33
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()
falsetru
  • 357,413
  • 63
  • 732
  • 636