It differs by driver. Here are two examples:
import MySQLdb dmc = MySQLdb.connect() r = dmc.cursor() r.execute('select %s, %s', ("foo", 2)) r._executed "select 'foo', 2" import psycopg2 connpc = psycopg2.connect() r = connpc.cursor() r.execute('select %s, %s', ('foo', 2)) r.query "select E'foo', 2"