#NEWLINE# @ _init_events . dispatch_for ( 'mysql' ) #NEWLINE# def _init_events( engine , mysql_sql_mode = None , **kw ) : #NEWLINE# #INDENT# 'Set up event listeners for MySQL.' #NEWLINE# if ( mysql_sql_mode is not None ) : #NEWLINE# #INDENT# @ sqlalchemy . event . listens_for ( engine , 'connect' ) #NEWLINE# def _set_session_sql_mode( dbapi_con , connection_rec ) : #NEWLINE# #INDENT# cursor = dbapi_con . cursor ( ) #NEWLINE# cursor . execute ( 'SET SESSION sql_mode = %s' , [ mysql_sql_mode ] ) #NEWLINE# #UNINDENT# #UNINDENT# @ sqlalchemy . event . listens_for ( engine , 'first_connect' ) #NEWLINE# def _check_effective_sql_mode( dbapi_con , connection_rec ) : #NEWLINE# #INDENT# if ( mysql_sql_mode is not None ) : #NEWLINE# #INDENT# _set_session_sql_mode ( dbapi_con , connection_rec ) #NEWLINE# #UNINDENT# cursor = dbapi_con . cursor ( ) #NEWLINE# cursor . execute ( "SHOW VARIABLES LIKE 'sql_mode'" ) #NEWLINE# realmode = cursor . fetchone ( ) #NEWLINE# if ( realmode is None ) : #NEWLINE# #INDENT# LOG . warning ( _LW ( 'Unable to detect effective SQL mode' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# realmode = realmode [ 1 ] #NEWLINE# LOG . debug ( 'MySQL server mode set to %s' , realmode ) #NEWLINE# if ( ( 'TRADITIONAL' not in realmode . upper ( ) ) and ( 'STRICT_ALL_TABLES' not in realmode . upper ( ) ) ) : #NEWLINE# #INDENT# LOG . warning ( _LW ( "MySQL SQL mode is '%s', consider enabling TRADITIONAL or STRICT_ALL_TABLES" ) , realmode )