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.
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.
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 })
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()