Python | Tarantool
Документация на русском языке
поддерживается сообществом

Python

tarantool-python is the official Python connector for Tarantool. It is not supplied as part of the Tarantool repository and must be installed separately (see below for details).

Далее приводится пример полноценной программы на языке Python, которая осуществляет вставку [99999,'Value','Value'] в спейс examples с помощью высокоуровневого API для языка Python.

#!/usr/bin/python
from tarantool import Connection

c = Connection("127.0.0.1", 3301)
result = c.insert("examples",(99999,'Value', 'Value'))
print result

Чтобы запустить тестовую программу, сохраните ее исходный код в файл с именем example.py и установите коннектор tarantool-python. Для установки коннектора воспользуйтесь либо командой pip install tarantool>0.4 (для установки в директорию /usr; вам потребуются права уровня root), либо командой pip install tarantool>0.4 --user (для установки в директорию ~, т.е. в используемую по умолчанию директорию текущего пользователя).

Before trying to run, check that the server instance is listening at localhost:3301 and that the space examples exists, as described earlier. To run the program, say python example.py. The program will connect to the Tarantool server, will send the INSERT request, and will not throw any exception if all went well. If the tuple already exists, the program will throw tarantool.error.DatabaseError: (3, "Duplicate key exists in unique index 'primary' in space 'examples'").

The example program only shows one request and does not show all that’s necessary for good practice. For that, please see tarantool-python project at GitHub. For an example of using Python API with queue managers for Tarantool, see queue-python project at GitHub.

Кроме того, сообщество разработчиков поддерживает другие Python-коннекторы:

The table below contains a feature comparison for asynctnt, gtarantool and tarantool-python. aiotarantool is absent there because it is quite outdated and unmaintained.

Last update: November 2022

Parameter igorcoding/asynctnt shveenkov/gtarantool tarantool/tarantool-python
License Apache License 2.0 LGPL BSD-2
Is maintained Yes No (last updated in 2016) Yes
Known Issues None None None
Documentation Yes (github.io) No Yes (readthedocs and tarantool.io)
Testing / CI / CD GitHub Actions No (tests exist) GitHub Actions
GitHub Stars 68 17 85
Static Analysis Yes (Flake8) No No
Packaging pip pip pip, deb, rpm
Code coverage Yes No Yes
Support asynchronous mode Yes, asyncio Yes (gevent, example: test_gevent.py) No
Batching support No No No (issue #55)
Schema reload Yes (automatically, see auto_refetch_schema) Yes (automatically) Yes (automatically)
Space / index names Yes Yes Yes
Access tuple fields by names Yes No No
SQL support Yes No Yes
Interactive transactions Yes No No (issue #163)
Varbinary support Yes (in MP_BIN fields) No Yes
Decimal support Yes No Yes
UUID support Yes No Yes
EXT_ERROR support Yes No Yes
Datetime support Yes No Yes
Interval support No (issue #30) No Yes
box.session.push() responses Yes No Yes
Session settings No No No
Graceful shutdown No No No
IPROTO_ID (feature discovery) Yes No Yes
CRUD support No No No (issue #205)
Transparent request retrying No No No
Transparent reconnecting Autoreconnect Yes (reconnect_max_attempts, reconnect_delay) Yes (reconnect_max_attempts, reconnect_delay), checking of connection liveness
Connection pool No No Yes (with master discovery)
Support of PEP 249 – Python Database API Specification v2.0 No No Yes
Encrypted connection (Tarantool Enterprise) No (issue #22) No Yes
Нашли ответ на свой вопрос?
Обратная связь