@@ -56,7 +56,7 @@ Throws an error if there is already a tuple with the same primary key.
56
56
... conn.insert(' demo' , (' BBBB' , ' Bravo' ))
57
57
... except Exception as exc:
58
58
... print (exc)
59
- ...
59
+ ...
60
60
(3 , ' Duplicate key exists in unique index "pk" in space "demo" with old tuple - ["BBBB", "Bravo"] and new tuple - ["BBBB", "Bravo"]' )
61
61
62
62
Replace
@@ -125,7 +125,7 @@ Creating a space instance
125
125
An instance of :class: `~tarantool.space.Space ` is a named object to access
126
126
the key space.
127
127
128
- Create a ``demo `` object that will be used to access the space
128
+ Create a ``demo `` object that will be used to access the space
129
129
with id ``'demo' ``:
130
130
131
131
.. code-block :: python
@@ -205,26 +205,26 @@ read-write and read-only pool instances:
205
205
Receiving out-of-band messages
206
206
----------------------------------
207
207
208
- Receiving out-of-band messages from a server that uses box.session.push
209
- call is supported for methods: :meth: `~tarantool.Connection.call `,
210
- :meth: `~tarantool.Connection.eval `, :meth: `~tarantool.Connection.select `,
211
- :meth: `~tarantool.Connection.insert `, :meth: `~tarantool.Connection.replace `,
212
- :meth: `~tarantool.Connection.update `, :meth: `~tarantool.Connection.upsert `,
208
+ Receiving out-of-band messages from a server that uses box.session.push
209
+ call is supported for methods: :meth: `~tarantool.Connection.call `,
210
+ :meth: `~tarantool.Connection.eval `, :meth: `~tarantool.Connection.select `,
211
+ :meth: `~tarantool.Connection.insert `, :meth: `~tarantool.Connection.replace `,
212
+ :meth: `~tarantool.Connection.update `, :meth: `~tarantool.Connection.upsert `,
213
213
:meth: `~tarantool.Connection.delete `.
214
214
215
- To work with out-of-band messages, 2 optional arguments are used in
215
+ To work with out-of-band messages, 2 optional arguments are used in
216
216
the methods listed above:
217
217
218
218
* `on_push ` - callback, launched with the received data for each out-of-band message. Two arguments for this callback are expected:
219
-
219
+
220
220
* the first is the received from an out-of-band message data.
221
221
222
222
* the second is `on_push_ctx `, variable for working with callback context (for example, recording the result or pass data to callback).
223
223
* `on_push_ctx ` - result of the `on_push ` work can be written to this variable, or through this variable you can pass data to `on_push ` callback.
224
224
225
- Below is an example of the proposed API with method :meth: `~tarantool.Connection.call `
226
- and :meth: `~tarantool.Connection.insert `. In the described example, before the end
227
- of the :meth: `~tarantool.Connection.call ` and :meth: `~tarantool.Connection.insert `,
225
+ Below is an example of the proposed API with method :meth: `~tarantool.Connection.call `
226
+ and :meth: `~tarantool.Connection.insert `. In the described example, before the end
227
+ of the :meth: `~tarantool.Connection.call ` and :meth: `~tarantool.Connection.insert `,
228
228
out-of-band messages are processed via specified callback.
229
229
230
230
In the example below, two shells are used, in the first we will configure the server:
@@ -249,7 +249,7 @@ In the example below, two shells are used, in the first we will configure the se
249
249
return x
250
250
end
251
251
252
- In the second shell, we will execute a :meth: `~tarantool.Connection.call `
252
+ In the second shell, we will execute a :meth: `~tarantool.Connection.call `
253
253
with receiving out-of-band messages from the server:
254
254
255
255
.. code-block :: python
@@ -266,11 +266,11 @@ with receiving out-of-band messages from the server:
266
266
conn = tarantool.Connection(port = 3301 )
267
267
res = conn.call(
268
268
' server_function' ,
269
- on_push = callback,
269
+ on_push = callback,
270
270
on_push_ctx = callback_res
271
271
)
272
272
273
- # receiving out-of-band messages,
273
+ # receiving out-of-band messages,
274
274
# the conn.call is not finished yet.
275
275
276
276
>> > run callback with data: [[1 , 0 ]]
@@ -285,7 +285,7 @@ with receiving out-of-band messages from the server:
285
285
print (callback_res)
286
286
>> > [[[1 , 1 ]], [[2 , 1 ]], [[3 , 1 ]]]
287
287
288
- Let's go back to the first shell with the server and
288
+ Let's go back to the first shell with the server and
289
289
create a space and a trigger for it:
290
290
291
291
.. code-block :: lua
@@ -315,7 +315,7 @@ create a space and a trigger for it:
315
315
on_replace_callback
316
316
)
317
317
318
- Now, in the second shell, we will execute an :meth: `~tarantool.ConnectionPool.insert `
318
+ Now, in the second shell, we will execute an :meth: `~tarantool.ConnectionPool.insert `
319
319
with out-of-band message processing:
320
320
321
321
.. code-block :: python
@@ -333,7 +333,7 @@ with out-of-band message processing:
333
333
on_push_ctx = callback_res,
334
334
)
335
335
336
- # receiving out-of-band messages,
336
+ # receiving out-of-band messages,
337
337
# the conn_pool.insert is not finished yet.
338
338
339
339
>> > run callback with data: [[100 , 0 ]]
@@ -352,7 +352,7 @@ with out-of-band message processing:
352
352
Interaction with the crud module
353
353
----------------------------------
354
354
355
- Through the :class: `~tarantool.Connection ` object, you can access
355
+ Through the :class: `~tarantool.Connection ` object, you can access
356
356
`crud module <https://github.com/tarantool/crud >`_ methods:
357
357
358
358
.. code-block :: python
@@ -362,16 +362,16 @@ Through the :class:`~tarantool.Connection` object, you can access
362
362
>> > conn = tarantool.Connection(host = ' localhost' ,port = 3301 ,fetch_schema = False )
363
363
364
364
>> > conn.crud_
365
- conn.crud_count( conn.crud_insert( conn.crud_insert_object_many(
366
- conn.crud_min( conn.crud_replace_object( conn.crud_stats(
367
- conn.crud_unflatten_rows( conn.crud_upsert_many( conn.crud_delete(
368
- conn.crud_insert_many( conn.crud_len( conn.crud_replace(
369
- conn.crud_replace_object_many( conn.crud_storage_info( conn.crud_update(
370
- conn.crud_upsert_object( conn.crud_get( conn.crud_insert_object(
371
- conn.crud_max( conn.crud_replace_many( conn.crud_select(
365
+ conn.crud_count( conn.crud_insert( conn.crud_insert_object_many(
366
+ conn.crud_min( conn.crud_replace_object( conn.crud_stats(
367
+ conn.crud_unflatten_rows( conn.crud_upsert_many( conn.crud_delete(
368
+ conn.crud_insert_many( conn.crud_len( conn.crud_replace(
369
+ conn.crud_replace_object_many( conn.crud_storage_info( conn.crud_update(
370
+ conn.crud_upsert_object( conn.crud_get( conn.crud_insert_object(
371
+ conn.crud_max( conn.crud_replace_many( conn.crud_select(
372
372
conn.crud_truncate( conn.crud_upsert( conn.crud_upsert_object_many(
373
373
374
- As an example, consider :meth:`~ tarantool.Connection.crud_insert` and :meth:`~ tarantool.Connection.crud_insert_object_many` .
374
+ As an example, consider :meth:`~ tarantool.Connection.crud_insert` and :meth:`~ tarantool.Connection.crud_insert_object_many` .
375
375
It is recommended to enclose calls in the try - except construction as follows:
376
376
377
377
.. code- block:: python
@@ -392,13 +392,13 @@ It is recommended to enclose calls in the try-except construction as follows:
392
392
... res = conn.crud_insert(' tester' , (3500 ,300 ,' Rob' ))
393
393
... except CrudModuleError as e:
394
394
... exc_crud = e
395
- ...
395
+ ...
396
396
>> > exc_crud
397
397
CrudModuleError(0 , ' Failed to insert: Duplicate key exists in unique index "primary_index" in space "tester" with old tuple - [3500, 300, "Rob"] and new tuple - [3500, 300, "Rob"]' )
398
398
>> > exc_crud.extra_info_error
399
399
< tarantool.crud.CrudError object at 0x 10a276950>
400
400
>> > exc_crud.extra_info_error.
401
- exc_crud.extra_info_error.class_name exc_crud.extra_info_error.err exc_crud.extra_info_error.file exc_crud.extra_info_error.line exc_crud.extra_info_error.str
401
+ exc_crud.extra_info_error.class_name exc_crud.extra_info_error.err exc_crud.extra_info_error.file exc_crud.extra_info_error.line exc_crud.extra_info_error.str
402
402
>> > exc_crud.extra_info_error.class_name
403
403
' InsertError'
404
404
>> > exc_crud.extra_info_error.str
@@ -409,7 +409,7 @@ It is recommended to enclose calls in the try-except construction as follows:
409
409
... res = conn.crud_insert_object_many(' tester' , ({' id' :3 ,' bucket_id' :100 ,' name' :' Ann' }, {' id' :4 ,' bucket_id' :100 ,' name' :' Sam' }), {' timeout' :100 , ' rollback_on_error' :False })
410
410
... except CrudModuleManyError as e:
411
411
... exc_crud = e
412
- ...
412
+ ...
413
413
>> > exc_crud
414
414
CrudModuleManyError(0 , ' Got multiple errors, see errors_list' )
415
415
>> > exc_crud.success_list # some of the rows were inserted.
@@ -422,7 +422,7 @@ It is recommended to enclose calls in the try-except construction as follows:
422
422
' CallError: Failed for 037adb3a-b9e3-4f78-a6d1-9f0cdb6cbefc: Function returned an error: Duplicate key exists in unique index "primary_index" in space "tester" with old tuple - [3500, 300, "Rob"] and new tuple - [3500, 100, "Mike"]'
423
423
>> > exc_crud.errors_list[1 ].str
424
424
' InsertManyError: Failed to flatten object: FlattenError: Object is specified in bad format: FlattenError: Unknown field "second_name" is specified'
425
-
425
+
426
426
# If there are no problems with any rows, the entire response will be contained in the res variable.
427
427
>> > res = conn.crud_insert_object_many(' tester' , ({' id' :3 ,' bucket_id' :100 ,' name' :' Ann' }, {' id' :4 ,' bucket_id' :100 ,' name' :' Sam' }), {' timeout' :100 , ' rollback_on_error' :False })
428
428
>> > res.rows
@@ -436,7 +436,7 @@ If module crud not found on the router or user has not sufficient grants:
436
436
... res = conn.crud_insert(' tester' , (22221 ,300 ,' Rob' ))
437
437
... except DatabaseError as e:
438
438
... exc_db = e
439
- ...
439
+ ...
440
440
>> > exc_db
441
441
DatabaseError(33 , " Procedure 'crud.insert' is not defined. Ensure that you're calling crud.router and user has sufficient grants" )
442
442
>> > exc_db.extra_info
0 commit comments