MySQL Connector/Python Developer Guide / ... / Connector/Python API Reference / connection.MySQLConnection Class / MySQLConnection.sql_mode Property
This property is used to retrieve and set the SQL Modes for the current connection. The value should be a list of different modes separated by comma (","), or a sequence of modes, preferably using theconstants.SQLMode class.
To unset all modes, pass an empty string or an empty sequence.
>>> cnx.sql_mode = 'TRADITIONAL,NO_ENGINE_SUBSTITUTION'>>> cnx.sql_mode.split(',')[u'STRICT_TRANS_TABLES', u'STRICT_ALL_TABLES', u'NO_ZERO_IN_DATE',u'NO_ZERO_DATE', u'ERROR_FOR_DIVISION_BY_ZERO', u'TRADITIONAL',u'NO_AUTO_CREATE_USER', u'NO_ENGINE_SUBSTITUTION']>>> from mysql.connector.constants import SQLMode>>> cnx.sql_mode = [ SQLMode.NO_ZERO_DATE, SQLMode.REAL_AS_FLOAT]>>> cnx.sql_modeu'REAL_AS_FLOAT,NO_ZERO_DATE'Returns a string.