here’s a recipe for emitting that SQL on every connection, as well as right up front on first connect which is optional, though if you plan on changing ANSI_QUOTES would need to happen before the dialect checks on sql_mode:
from sqlalchemy import create_engine, event
eng = create_engine("mysql://scott:tiger@localhost/test", echo='debug')
@event.listens_for(eng, "first_connect", insert=True) # make sure we're the very first thing
@event.listens_for(eng, "connect")
def connect(dbapi_connection, connection_record):
cursor = dbapi_connection.cursor()
cursor.execute("SET sql_mode = 'STRICT_ALL_TABLES'")
conn = eng.connect()
> --
> You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
sqlalchemy+...@googlegroups.com.
> To post to this group, send email to
sqlal...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/sqlalchemy.
> For more options, visit
https://groups.google.com/groups/opt_out.