50
50
ITERATOR_ALL
51
51
)
52
52
from tarantool .error import (
53
+ Error ,
53
54
NetworkError ,
54
55
DatabaseError ,
55
56
InterfaceError ,
56
57
SchemaError ,
57
58
NetworkWarning ,
59
+ OperationalError ,
60
+ DataError ,
61
+ IntegrityError ,
62
+ InternalError ,
63
+ ProgrammingError ,
64
+ NotSupportedError ,
58
65
SchemaReloadException ,
66
+ Warning ,
59
67
warn
60
68
)
61
69
from tarantool .schema import Schema
@@ -77,11 +85,20 @@ class Connection(object):
77
85
Also this class provides low-level interface to data manipulation
78
86
(insert/delete/update/select).
79
87
'''
80
- Error = tarantool .error
88
+ # DBAPI Extension: supply exceptions as attributes on the connection
89
+ Error = Error
81
90
DatabaseError = DatabaseError
82
91
InterfaceError = InterfaceError
83
92
SchemaError = SchemaError
84
93
NetworkError = NetworkError
94
+ Warning = Warning
95
+ DataError = DataError
96
+ OperationalError = OperationalError
97
+ IntegrityError = IntegrityError
98
+ InternalError = InternalError
99
+ ProgrammingError = ProgrammingError
100
+ NotSupportedError = NotSupportedError
101
+ ImproperlyConfigured = Exception
85
102
86
103
def __init__ (self , host , port ,
87
104
user = None ,
@@ -92,6 +109,7 @@ def __init__(self, host, port,
92
109
connect_now = True ,
93
110
encoding = ENCODING_DEFAULT ,
94
111
call_16 = False ,
112
+ use_list = True ,
95
113
connection_timeout = CONNECTION_TIMEOUT ):
96
114
'''
97
115
Initialize a connection to the server.
@@ -124,6 +142,7 @@ def __init__(self, host, port,
124
142
self ._socket = None
125
143
self .connected = False
126
144
self .error = True
145
+ self .use_list = use_list
127
146
self .encoding = encoding
128
147
self .call_16 = call_16
129
148
self .connection_timeout = connection_timeout
@@ -261,7 +280,7 @@ def _send_request_wo_reconnect(self, request):
261
280
while True :
262
281
try :
263
282
self ._socket .sendall (bytes (request ))
264
- response = Response (self , self ._read_response ())
283
+ response = Response (self , self ._read_response (), self . use_list )
265
284
break
266
285
except SchemaReloadException as e :
267
286
self .update_schema (e .schema_version )
@@ -299,7 +318,6 @@ def check(): # Check that connection is alive
299
318
err = ctypes .get_last_error ()
300
319
self ._socket .setblocking (True )
301
320
302
-
303
321
WWSAEWOULDBLOCK = 10035
304
322
if (retbytes < 0 ) and (err == errno .EAGAIN or
305
323
err == errno .EWOULDBLOCK or
@@ -446,7 +464,7 @@ def _join_v16(self, server_uuid):
446
464
self ._socket .sendall (bytes (request ))
447
465
448
466
while True :
449
- resp = Response (self , self ._read_response ())
467
+ resp = Response (self , self ._read_response (), self . use_list )
450
468
yield resp
451
469
if resp .code == REQUEST_TYPE_OK or resp .code >= REQUEST_TYPE_ERROR :
452
470
return
@@ -460,7 +478,7 @@ class JoinState:
460
478
self ._socket .sendall (bytes (request ))
461
479
state = JoinState .Handshake
462
480
while True :
463
- resp = Response (self , self ._read_response ())
481
+ resp = Response (self , self ._read_response (), self . use_list )
464
482
yield resp
465
483
if resp .code >= REQUEST_TYPE_ERROR :
466
484
return
@@ -489,7 +507,7 @@ def subscribe(self, cluster_uuid, server_uuid, vclock=None):
489
507
request = RequestSubscribe (self , cluster_uuid , server_uuid , vclock )
490
508
self ._socket .sendall (bytes (request ))
491
509
while True :
492
- resp = Response (self , self ._read_response ())
510
+ resp = Response (self , self ._read_response (), self . use_list )
493
511
yield resp
494
512
if resp .code >= REQUEST_TYPE_ERROR :
495
513
return
0 commit comments