MySQL-Python does nothing special, it simply encodes each argument to prevent SQL injections, and uses the standard Python % operator to replace %s placeholders with encoded arguments.
If you really want to see the result, run the same code as cursor.execute() :
from MySQLdb.converters import get_codec def prepare_sql(cursor, query, args=None): if args is not None: query = query % tuple(( get_codec(a, cursor.encoders)(db, a) for a in args )) return query
See the definition of execute() starting at line 168 in MySQLdb/cursors.py .
source share