@@ -200,10 +200,6 @@ class object, used to create cursors (keyword only)
200
200
)
201
201
202
202
self .encoding = "ascii" # overridden in set_character_set()
203
- db = proxy (self )
204
-
205
- def unicode_literal (u , dummy = None ):
206
- return db .string_literal (u .encode (db .encoding ))
207
203
208
204
if not charset :
209
205
charset = self .character_set_name ()
@@ -227,7 +223,13 @@ def unicode_literal(u, dummy=None):
227
223
# MySQL may return JSON with charset==binary.
228
224
self .converter [FIELD_TYPE .JSON ] = str
229
225
226
+ db = proxy (self )
227
+
228
+ def unicode_literal (u , dummy = None ):
229
+ return db .string_literal (u .encode (db .encoding ))
230
+
230
231
self .encoders [str ] = unicode_literal
232
+
231
233
self ._transactional = self .server_capabilities & CLIENT .TRANSACTIONS
232
234
if self ._transactional :
233
235
if autocommit is not None :
@@ -300,32 +302,10 @@ def begin(self):
300
302
"""
301
303
self .query (b"BEGIN" )
302
304
303
- if not hasattr (_mysql .connection , "warning_count" ):
304
-
305
- def warning_count (self ):
306
- """Return the number of warnings generated from the
307
- last query. This is derived from the info() method."""
308
- info = self .info ()
309
- if info :
310
- return int (info .split ()[- 1 ])
311
- else :
312
- return 0
313
-
314
305
def set_character_set (self , charset ):
315
- """Set the connection character set to charset. The character
316
- set can only be changed in MySQL-4.1 and newer. If you try
317
- to change the character set from the current value in an
318
- older version, NotSupportedError will be raised."""
319
- py_charset = _charset_to_encoding .get (charset , charset )
320
- if self .character_set_name () != charset :
321
- try :
322
- super ().set_character_set (charset )
323
- except AttributeError :
324
- if self ._server_version < (4 , 1 ):
325
- raise NotSupportedError ("server is too old to set charset" )
326
- self .query ("SET NAMES %s" % charset )
327
- self .store_result ()
328
- self .encoding = py_charset
306
+ """Set the connection character set to charset."""
307
+ super ().set_character_set (charset )
308
+ self .encoding = _charset_to_encoding .get (charset , charset )
329
309
330
310
def set_sql_mode (self , sql_mode ):
331
311
"""Set the connection sql_mode. See MySQL documentation for
0 commit comments