2
2
Supports python 3.6 and above
3
3
"""
4
4
import re
5
- from collections import deque
6
5
from copy import deepcopy
7
- from itertools import islice
8
6
9
- from pycallgraph import PyCallGraph
10
- from pycallgraph .output import GraphvizOutput
11
-
12
- from tarantool .error import InterfaceError , ProgrammingError
7
+ from tarantool .error import InterfaceError
13
8
14
9
from .connection import Connection as BaseConnection
15
10
16
11
17
12
class Cursor :
18
13
_lastrowid = 0
14
+ _rowcount = 0
19
15
description = None
20
16
position = 0
21
- arraysize = 100
17
+ arraysize = 200
22
18
autocommit = True
23
- _rowcount = 0
24
19
ui_pattern = re .compile (r'^(UPDATE|INSERT)' )
25
20
u_pattern = re .compile (r'^INSERT' )
26
21
@@ -43,18 +38,17 @@ def _convert_param(p):
43
38
return "'%s'" % p
44
39
45
40
@staticmethod
46
- def extract_last_row_id (body ): # Need to be checked
41
+ def _extract_last_row_id (body ): # Need to be checked
47
42
try :
48
43
val = tuple (tuple (body .items ())[0 ][- 1 ].items ())[- 1 ][- 1 ][0 ]
49
44
except TypeError :
50
- val = 1
45
+ val = - 1
51
46
return val
52
47
53
48
def execute (self , query , params = None ):
54
49
if params :
55
50
query = query % tuple (self ._convert_param (param ) for param in params )
56
51
57
- # print(query)
58
52
response = self ._c .execute (query )
59
53
60
54
self .rows = tuple (response .body .values ())[1 ] if len (response .body ) > 1 else []
@@ -68,9 +62,12 @@ def execute(self, query, params=None):
68
62
self ._rowcount = 1
69
63
70
64
if self .u_pattern .match (query ):
71
- self ._lastrowid = self .extract_last_row_id (response .body )
65
+ self ._lastrowid = self ._extract_last_row_id (response .body )
72
66
return response
73
67
68
+ def executemany (self , query , params ):
69
+ return self .execute (query , params )
70
+
74
71
@property
75
72
def lastrowid (self ):
76
73
return self ._lastrowid
@@ -79,9 +76,6 @@ def lastrowid(self):
79
76
def rowcount (self ):
80
77
return self ._rowcount
81
78
82
- def executemany (self , query , params ):
83
- return self .execute (query , params )
84
-
85
79
def fetchone (self ):
86
80
return self .rows [0 ] if len (self .rows ) else None
87
81
0 commit comments