@@ -363,7 +363,8 @@ def __init__(self, host, port,
363
363
ssl_ca_file = DEFAULT_SSL_CA_FILE ,
364
364
ssl_ciphers = DEFAULT_SSL_CIPHERS ,
365
365
packer_factory = default_packer_factory ,
366
- unpacker_factory = default_unpacker_factory ):
366
+ unpacker_factory = default_unpacker_factory ,
367
+ fetch_schema = True ):
367
368
"""
368
369
:param host: Server hostname or IP address. Use ``None`` for
369
370
Unix sockets.
@@ -503,6 +504,17 @@ def __init__(self, host, port,
503
504
callable[[:obj:`~tarantool.Connection`], :obj:`~msgpack.Unpacker`],
504
505
optional
505
506
507
+ :param bool fetch_schema: If ``False``, allows to ignore schema
508
+ changes on the server, schema updates are not automatically
509
+ loaded. As a result, the methods become unavailable:
510
+ :meth:`~tarantool.Connection.replace`,
511
+ :meth:`~tarantool.Connection.insert`,
512
+ :meth:`~tarantool.Connection.delete`,
513
+ :meth:`~tarantool.Connection.upsert`,
514
+ :meth:`~tarantool.Connection.update`,
515
+ :meth:`~tarantool.Connection.select`.
516
+ :type fetch_schema: :obj:`bool`, optional
517
+
506
518
:raise: :exc:`~tarantool.error.ConfigurationError`,
507
519
:meth:`~tarantool.Connection.connect` exceptions
508
520
@@ -533,8 +545,10 @@ def __init__(self, host, port,
533
545
self .socket_timeout = socket_timeout
534
546
self .reconnect_delay = reconnect_delay
535
547
self .reconnect_max_attempts = reconnect_max_attempts
536
- self .schema = Schema (self )
537
- self .schema_version = 1
548
+ self .fetch_schema = fetch_schema
549
+ if self .fetch_schema :
550
+ self .schema = Schema (self )
551
+ self .schema_version = 1
538
552
self ._socket = None
539
553
self .connected = False
540
554
self .error = True
@@ -745,7 +759,8 @@ def connect(self):
745
759
if self .transport == SSL_TRANSPORT :
746
760
self .wrap_socket_ssl ()
747
761
self .handshake ()
748
- self .load_schema ()
762
+ if self .fetch_schema :
763
+ self .load_schema ()
749
764
self ._check_features ()
750
765
except SslError as e :
751
766
raise e
@@ -841,7 +856,8 @@ def _send_request_wo_reconnect(self, request, on_push=None, on_push_ctx=None):
841
856
response = request .response_class (self , self ._read_response ())
842
857
break
843
858
except SchemaReloadException as e :
844
- self .update_schema (e .schema_version )
859
+ if self .fetch_schema :
860
+ self .update_schema (e .schema_version )
845
861
continue
846
862
847
863
while response ._code == IPROTO_CHUNK :
@@ -1089,11 +1105,16 @@ def replace(self, space_name, values, on_push=None, on_push_ctx=None):
1089
1105
:exc:`~tarantool.error.DatabaseError`,
1090
1106
:exc:`~tarantool.error.SchemaError`,
1091
1107
:exc:`~tarantool.error.NetworkError`,
1092
- :exc:`~tarantool.error.SslError`
1108
+ :exc:`~tarantool.error.SslError`,
1109
+ :exc:`~tarantool.error.NotSupportedError`
1093
1110
1094
1111
.. _replace: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/replace/
1095
1112
"""
1096
1113
1114
+ if not self .fetch_schema :
1115
+ raise NotSupportedError ('This method is not available in ' +
1116
+ 'connection opened with fetch_schema=False' )
1117
+
1097
1118
if isinstance (space_name , str ):
1098
1119
space_name = self .schema .get_space (space_name ).sid
1099
1120
if on_push is not None and not callable (on_push ):
@@ -1276,11 +1297,16 @@ def insert(self, space_name, values, on_push=None, on_push_ctx=None):
1276
1297
:exc:`~tarantool.error.DatabaseError`,
1277
1298
:exc:`~tarantool.error.SchemaError`,
1278
1299
:exc:`~tarantool.error.NetworkError`,
1279
- :exc:`~tarantool.error.SslError`
1300
+ :exc:`~tarantool.error.SslError`,
1301
+ :exc:`~tarantool.error.NotSupportedError`
1280
1302
1281
1303
.. _insert: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/insert/
1282
1304
"""
1283
1305
1306
+ if not self .fetch_schema :
1307
+ raise NotSupportedError ('This method is not available in ' +
1308
+ 'connection opened with fetch_schema=False' )
1309
+
1284
1310
if isinstance (space_name , str ):
1285
1311
space_name = self .schema .get_space (space_name ).sid
1286
1312
if on_push is not None and not callable (on_push ):
@@ -1315,11 +1341,16 @@ def delete(self, space_name, key, *, index=0, on_push=None, on_push_ctx=None):
1315
1341
:exc:`~tarantool.error.DatabaseError`,
1316
1342
:exc:`~tarantool.error.SchemaError`,
1317
1343
:exc:`~tarantool.error.NetworkError`,
1318
- :exc:`~tarantool.error.SslError`
1344
+ :exc:`~tarantool.error.SslError`,
1345
+ :exc:`~tarantool.error.NotSupportedError`
1319
1346
1320
1347
.. _delete: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/delete/
1321
1348
"""
1322
1349
1350
+ if not self .fetch_schema :
1351
+ raise NotSupportedError ('This method is not available in ' +
1352
+ 'connection opened with fetch_schema=False' )
1353
+
1323
1354
key = wrap_key (key )
1324
1355
if isinstance (space_name , str ):
1325
1356
space_name = self .schema .get_space (space_name ).sid
@@ -1374,11 +1405,16 @@ def upsert(self, space_name, tuple_value, op_list, *, index=0, on_push=None, on_
1374
1405
:exc:`~tarantool.error.DatabaseError`,
1375
1406
:exc:`~tarantool.error.SchemaError`,
1376
1407
:exc:`~tarantool.error.NetworkError`,
1377
- :exc:`~tarantool.error.SslError`
1408
+ :exc:`~tarantool.error.SslError`,
1409
+ :exc:`~tarantool.error.NotSupportedError`
1378
1410
1379
1411
.. _upsert: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/upsert/
1380
1412
"""
1381
1413
1414
+ if not self .fetch_schema :
1415
+ raise NotSupportedError ('This method is not available in ' +
1416
+ 'connection opened with fetch_schema=False' )
1417
+
1382
1418
if isinstance (space_name , str ):
1383
1419
space_name = self .schema .get_space (space_name ).sid
1384
1420
if isinstance (index , str ):
@@ -1462,11 +1498,16 @@ def update(self, space_name, key, op_list, *, index=0, on_push=None, on_push_ctx
1462
1498
:exc:`~tarantool.error.DatabaseError`,
1463
1499
:exc:`~tarantool.error.SchemaError`,
1464
1500
:exc:`~tarantool.error.NetworkError`,
1465
- :exc:`~tarantool.error.SslError`
1501
+ :exc:`~tarantool.error.SslError`,
1502
+ :exc:`~tarantool.error.NotSupportedError`
1466
1503
1467
1504
.. _update: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/update/
1468
1505
"""
1469
1506
1507
+ if not self .fetch_schema :
1508
+ raise NotSupportedError ('This method is not available in ' +
1509
+ 'connection opened with fetch_schema=False' )
1510
+
1470
1511
key = wrap_key (key )
1471
1512
if isinstance (space_name , str ):
1472
1513
space_name = self .schema .get_space (space_name ).sid
@@ -1648,11 +1689,16 @@ def select(self, space_name, key=None, *, offset=0, limit=0xffffffff, index=0, i
1648
1689
:exc:`~tarantool.error.DatabaseError`,
1649
1690
:exc:`~tarantool.error.SchemaError`,
1650
1691
:exc:`~tarantool.error.NetworkError`,
1651
- :exc:`~tarantool.error.SslError`
1692
+ :exc:`~tarantool.error.SslError`,
1693
+ :exc:`~tarantool.error.NotSupportedError`
1652
1694
1653
1695
.. _select: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/select/
1654
1696
"""
1655
1697
1698
+ if not self .fetch_schema :
1699
+ raise NotSupportedError ('This method is not available in ' +
1700
+ 'connection opened with fetch_schema=False' )
1701
+
1656
1702
if iterator is None :
1657
1703
iterator = ITERATOR_EQ
1658
1704
if key is None or (isinstance (key , (list , tuple )) and
0 commit comments