Beispiel #1
0
 def set_sql_mode(self, sql_mode):
     """Set the connection sql_mode. See MySQL documentation for
     legal values."""
     if self._server_version < (4, 1):
         raise NotSupportedError("server is too old to set sql_mode")
     self.query("SET SESSION sql_mode='%s'" % sql_mode)
     self.store_result()
Beispiel #2
0
 def set_character_set(self, charset):
     """Set the connection character set to charset. The character
     set can only be changed in MySQL-4.1 and newer. If you try
     to change the character set from the current value in an
     older version, NotSupportedError will be raised."""
     py_charset = _charset_to_encoding.get(charset, charset)
     if self.character_set_name() != charset:
         try:
             super(Connection, self).set_character_set(charset)
         except AttributeError:
             if self._server_version < (4, 1):
                 raise NotSupportedError("server is too old to set charset")
             self.query('SET NAMES %s' % charset)
             self.store_result()
     self.encoding = py_charset