I have a string, specifically a SQL query, that goes through multiple formatting passes before it is passed to the backend to be executed, at which point Django performs yet another string format. How can I preserve the placeholders that need to make it to the database throughout all of this? Something like the following is the best I've come up with, but is definitely not as flexible as I need it to be. I am running Python 2.5
from django.db import connection
cursor = connection.cursor()
cursor.execute("SELECT DATE_FORMAT('2010-01-01 12:00:00', '%%%%H:%%%%i:%%%%s') as %s" % 'foo')