DBI spec and parameter passing
Skip Montanaro
skip at mojam.com
Tue Jan 18 11:24:19 EST 2000
>> Instead of doing the parameter interpolation yourself, try letting
>> your database module do it for you, e.g.:
>>
>> c = db.cursor()
>> c.execute("""select id from city where"""
>> """ city = %s and"""
>> """ state = %s and"""
>> """ country = %s""", (city, state, country))
Gordon> but Skip _meant_:
Gordon> c.execute(""" select id from city where city = ? and state = ?
Gordon> and country = ?""", (city, state, country))
I suppose so, in the correct context. Not being an ODBC person I didn't
know what was required in the context of the original question, so all I
could do was cut/paste from my MySQLdb code, which wants the %s thingies...
Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/
847-971-7098
More information about the Python-list
mailing list