@@ -224,16 +224,16 @@ def execute(self, query, args=None):
224
224
225
225
def executemany (self , query , args ):
226
226
"""Execute a multi-row query.
227
-
227
+
228
228
query -- string, query to execute on server
229
229
230
230
args
231
231
232
232
Sequence of sequences or mappings, parameters to use with
233
233
query.
234
-
234
+
235
235
Returns long integer rows affected, if any.
236
-
236
+
237
237
This method improves performance on multiple-row INSERT and
238
238
REPLACE. Otherwise it is equivalent to looping over args with
239
239
execute().
@@ -279,11 +279,10 @@ def executemany(self, query, args):
279
279
r = self ._query (qs )
280
280
if not self ._defer_warnings : self ._warning_check ()
281
281
return r
282
-
283
- def callproc (self , procname , args = ()):
284
282
283
+ def callproc (self , procname , args = ()):
285
284
"""Execute stored procedure procname with args
286
-
285
+
287
286
procname -- string, name of procedure to execute on server
288
287
289
288
args -- Sequence of parameters to use with procedure
@@ -318,26 +317,28 @@ def callproc(self, procname, args=()):
318
317
q = q .encode (db .unicode_literal .charset )
319
318
self ._query (q )
320
319
self .nextset ()
321
-
320
+
322
321
q = "CALL %s(%s)" % (procname ,
323
322
',' .join (['@_%s_%d' % (procname , i )
324
323
for i in range (len (args ))]))
325
324
if isinstance (q , unicode ):
326
325
q = q .encode (db .unicode_literal .charset )
327
326
self ._query (q )
328
327
self ._executed = q
329
- if not self ._defer_warnings : self ._warning_check ()
328
+ if not self ._defer_warnings :
329
+ self ._warning_check ()
330
330
return args
331
-
331
+
332
332
def _do_query (self , q ):
333
333
db = self ._get_db ()
334
334
self ._last_executed = q
335
335
db .query (q )
336
336
self ._do_get_result ()
337
337
return self .rowcount
338
338
339
- def _query (self , q ): return self ._do_query (q )
340
-
339
+ def _query (self , q ):
340
+ return self ._do_query (q )
341
+
341
342
def _fetch_row (self , size = 1 ):
342
343
if not self ._result :
343
344
return ()
@@ -356,7 +357,7 @@ def __iter__(self):
356
357
InternalError = InternalError
357
358
ProgrammingError = ProgrammingError
358
359
NotSupportedError = NotSupportedError
359
-
360
+
360
361
361
362
class CursorStoreResultMixIn (object ):
362
363
@@ -403,11 +404,11 @@ def fetchall(self):
403
404
result = self ._rows
404
405
self .rownumber = len (self ._rows )
405
406
return result
406
-
407
+
407
408
def scroll (self , value , mode = 'relative' ):
408
409
"""Scroll the cursor in the result set to a new position according
409
410
to mode.
410
-
411
+
411
412
If mode is 'relative' (default), value is taken as offset to
412
413
the current position in the result set, if set to 'absolute',
413
414
value states an absolute target position."""
@@ -427,7 +428,7 @@ def __iter__(self):
427
428
self ._check_executed ()
428
429
result = self .rownumber and self ._rows [self .rownumber :] or self ._rows
429
430
return iter (result )
430
-
431
+
431
432
432
433
class CursorUseResultMixIn (object ):
433
434
@@ -438,7 +439,7 @@ class CursorUseResultMixIn(object):
438
439
the connection."""
439
440
440
441
_defer_warnings = True
441
-
442
+
442
443
def _get_result (self ): return self ._get_db ().use_result ()
443
444
444
445
def fetchone (self ):
@@ -450,7 +451,7 @@ def fetchone(self):
450
451
return None
451
452
self .rownumber = self .rownumber + 1
452
453
return r [0 ]
453
-
454
+
454
455
def fetchmany (self , size = None ):
455
456
"""Fetch up to size rows from the cursor. Result set may be smaller
456
457
than size. If size is not defined, cursor.arraysize is used."""
@@ -460,7 +461,7 @@ def fetchmany(self, size=None):
460
461
if not r :
461
462
self ._warning_check ()
462
463
return r
463
-
464
+
464
465
def fetchall (self ):
465
466
"""Fetchs all available rows from the cursor."""
466
467
self ._check_executed ()
@@ -477,18 +478,18 @@ def next(self):
477
478
if row is None :
478
479
raise StopIteration
479
480
return row
480
-
481
481
482
- class CursorTupleRowsMixIn (object ):
482
+ __next__ = next
483
+
483
484
485
+ class CursorTupleRowsMixIn (object ):
484
486
"""This is a MixIn class that causes all rows to be returned as tuples,
485
487
which is the standard form required by DB API."""
486
488
487
489
_fetch_type = 0
488
490
489
491
490
492
class CursorDictRowsMixIn (object ):
491
-
492
493
"""This is a MixIn class that causes all rows to be returned as
493
494
dictionaries. This is a non-standard feature."""
494
495
@@ -520,7 +521,6 @@ def fetchallDict(self):
520
521
521
522
522
523
class CursorOldDictRowsMixIn (CursorDictRowsMixIn ):
523
-
524
524
"""This is a MixIn class that returns rows as dictionaries with
525
525
the same key convention as the old Mysqldb (MySQLmodule). Don't
526
526
use this."""
@@ -530,28 +530,24 @@ class CursorOldDictRowsMixIn(CursorDictRowsMixIn):
530
530
531
531
class Cursor (CursorStoreResultMixIn , CursorTupleRowsMixIn ,
532
532
BaseCursor ):
533
-
534
533
"""This is the standard Cursor class that returns rows as tuples
535
534
and stores the result set in the client."""
536
535
537
536
538
537
class DictCursor (CursorStoreResultMixIn , CursorDictRowsMixIn ,
539
538
BaseCursor ):
540
-
541
539
"""This is a Cursor class that returns rows as dictionaries and
542
540
stores the result set in the client."""
543
-
541
+
544
542
545
543
class SSCursor (CursorUseResultMixIn , CursorTupleRowsMixIn ,
546
544
BaseCursor ):
547
-
548
545
"""This is a Cursor class that returns rows as tuples and stores
549
546
the result set in the server."""
550
547
551
548
552
549
class SSDictCursor (CursorUseResultMixIn , CursorDictRowsMixIn ,
553
550
BaseCursor ):
554
-
555
551
"""This is a Cursor class that returns rows as dictionaries and
556
552
stores the result set in the server."""
557
553
0 commit comments