Current situation:
class MyQueries:
SWEET_QUERY = "SELECT * FROM {foo};"
# ... later
schema_editor.execute(
psycopg_sql.SQL(MyQueries.SWEET_QUERY)
.format(foo=psycopg_sql.Literal(foo))
.as_string(schema_editor.connection.connection)
)
We can change that so that the SQL wrapper is defined directly in the query
definition
class MyQueries:
SWEET_QUERY = psycopg_sql.SQL("SELECT * FROM {foo};")