document the "insert" flag for event.listen and add example regarding setting flags, also mention this re: mysql sql_mode

Issue #2937 new
Mike Bayer repo owner created an issue
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()

Comments (8)

  1. Log in to comment