11
11
12
12
import ctypes
13
13
import ctypes .util
14
+
14
15
try :
15
16
from ctypes import c_ssize_t
16
17
except ImportError :
50
51
ITERATOR_ALL
51
52
)
52
53
from tarantool .error import (
54
+ Error ,
53
55
NetworkError ,
54
56
DatabaseError ,
55
57
InterfaceError ,
56
58
SchemaError ,
57
59
NetworkWarning ,
60
+ OperationalError ,
61
+ DataError ,
62
+ IntegrityError ,
63
+ InternalError ,
64
+ ProgrammingError ,
65
+ NotSupportedError ,
58
66
SchemaReloadException ,
67
+ Warning ,
59
68
warn
60
69
)
61
70
from tarantool .schema import Schema
@@ -77,11 +86,20 @@ class Connection(object):
77
86
Also this class provides low-level interface to data manipulation
78
87
(insert/delete/update/select).
79
88
'''
80
- Error = tarantool .error
89
+ # DBAPI Extension: supply exceptions as attributes on the connection
90
+ Error = Error
81
91
DatabaseError = DatabaseError
82
92
InterfaceError = InterfaceError
83
93
SchemaError = SchemaError
84
94
NetworkError = NetworkError
95
+ Warning = Warning
96
+ DataError = DataError
97
+ OperationalError = OperationalError
98
+ IntegrityError = IntegrityError
99
+ InternalError = InternalError
100
+ ProgrammingError = ProgrammingError
101
+ NotSupportedError = NotSupportedError
102
+ ImproperlyConfigured = Exception
85
103
86
104
def __init__ (self , host , port ,
87
105
user = None ,
@@ -92,6 +110,7 @@ def __init__(self, host, port,
92
110
connect_now = True ,
93
111
encoding = ENCODING_DEFAULT ,
94
112
call_16 = False ,
113
+ use_list = True ,
95
114
connection_timeout = CONNECTION_TIMEOUT ):
96
115
'''
97
116
Initialize a connection to the server.
@@ -124,6 +143,7 @@ def __init__(self, host, port,
124
143
self ._socket = None
125
144
self .connected = False
126
145
self .error = True
146
+ self .use_list = use_list
127
147
self .encoding = encoding
128
148
self .call_16 = call_16
129
149
self .connection_timeout = connection_timeout
@@ -261,7 +281,7 @@ def _send_request_wo_reconnect(self, request):
261
281
while True :
262
282
try :
263
283
self ._socket .sendall (bytes (request ))
264
- response = Response (self , self ._read_response ())
284
+ response = Response (self , self ._read_response (), self . use_list )
265
285
break
266
286
except SchemaReloadException as e :
267
287
self .update_schema (e .schema_version )
@@ -293,13 +313,12 @@ def check(): # Check that connection is alive
293
313
retbytes = self ._sys_recv (sock_fd , buf , 1 , flag )
294
314
295
315
err = 0
296
- if os .name != 'nt' :
316
+ if os .name != 'nt' :
297
317
err = ctypes .get_errno ()
298
318
else :
299
319
err = ctypes .get_last_error ()
300
320
self ._socket .setblocking (True )
301
321
302
-
303
322
WWSAEWOULDBLOCK = 10035
304
323
if (retbytes < 0 ) and (err == errno .EAGAIN or
305
324
err == errno .EWOULDBLOCK or
@@ -446,7 +465,7 @@ def _join_v16(self, server_uuid):
446
465
self ._socket .sendall (bytes (request ))
447
466
448
467
while True :
449
- resp = Response (self , self ._read_response ())
468
+ resp = Response (self , self ._read_response (), self . use_list )
450
469
yield resp
451
470
if resp .code == REQUEST_TYPE_OK or resp .code >= REQUEST_TYPE_ERROR :
452
471
return
@@ -460,7 +479,7 @@ class JoinState:
460
479
self ._socket .sendall (bytes (request ))
461
480
state = JoinState .Handshake
462
481
while True :
463
- resp = Response (self , self ._read_response ())
482
+ resp = Response (self , self ._read_response (), self . use_list )
464
483
yield resp
465
484
if resp .code >= REQUEST_TYPE_ERROR :
466
485
return
@@ -489,7 +508,7 @@ def subscribe(self, cluster_uuid, server_uuid, vclock=None):
489
508
request = RequestSubscribe (self , cluster_uuid , server_uuid , vclock )
490
509
self ._socket .sendall (bytes (request ))
491
510
while True :
492
- resp = Response (self , self ._read_response ())
511
+ resp = Response (self , self ._read_response (), self . use_list )
493
512
yield resp
494
513
if resp .code >= REQUEST_TYPE_ERROR :
495
514
return
@@ -791,10 +810,10 @@ def execute(self, query, params=None):
791
810
'''
792
811
Execute SQL request.
793
812
Execute SQL query in database.
794
-
795
- :param query: SQL syntax query
813
+
814
+ :param query: SQL syntax query
796
815
:type query: str
797
-
816
+
798
817
:param params: Bind values to use in query
799
818
:type params: list, dict
800
819
0 commit comments