Skip to content

Commit 5d93a80

Browse files
committed
minor changes
1 parent 0332c53 commit 5d93a80

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

tarantool/dbapi.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,20 @@
22
Supports python 3.6 and above
33
"""
44
import re
5-
from collections import deque
65
from copy import deepcopy
7-
from itertools import islice
86

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
138

149
from .connection import Connection as BaseConnection
1510

1611

1712
class Cursor:
1813
_lastrowid = 0
14+
_rowcount = 0
1915
description = None
2016
position = 0
21-
arraysize = 100
17+
arraysize = 200
2218
autocommit = True
23-
_rowcount = 0
2419
ui_pattern = re.compile(r'^(UPDATE|INSERT)')
2520
u_pattern = re.compile(r'^INSERT')
2621

@@ -43,18 +38,17 @@ def _convert_param(p):
4338
return "'%s'" % p
4439

4540
@staticmethod
46-
def extract_last_row_id(body): # Need to be checked
41+
def _extract_last_row_id(body): # Need to be checked
4742
try:
4843
val = tuple(tuple(body.items())[0][-1].items())[-1][-1][0]
4944
except TypeError:
50-
val = 1
45+
val = -1
5146
return val
5247

5348
def execute(self, query, params=None):
5449
if params:
5550
query = query % tuple(self._convert_param(param) for param in params)
5651

57-
# print(query)
5852
response = self._c.execute(query)
5953

6054
self.rows = tuple(response.body.values())[1] if len(response.body) > 1 else []
@@ -68,9 +62,12 @@ def execute(self, query, params=None):
6862
self._rowcount = 1
6963

7064
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)
7266
return response
7367

68+
def executemany(self, query, params):
69+
return self.execute(query, params)
70+
7471
@property
7572
def lastrowid(self):
7673
return self._lastrowid
@@ -79,9 +76,6 @@ def lastrowid(self):
7976
def rowcount(self):
8077
return self._rowcount
8178

82-
def executemany(self, query, params):
83-
return self.execute(query, params)
84-
8579
def fetchone(self):
8680
return self.rows[0] if len(self.rows) else None
8781

0 commit comments

Comments
 (0)