Python | Tarantool
Tarantool
Check out the new release policy
Connectors Python

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).

Here is a complete Python program that inserts [99999,'Value','Value'] into space examples via the high-level Python API.

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

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

To prepare, paste the code into a file named example.py and install the tarantool-python connector with either pip install tarantool>0.4 to install in /usr (requires root privilege) or pip install tarantool>0.4 --user to install in ~ i.e. user’s default directory.

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.

Also there are several community-driven Python connectors:

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: July 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 (tarantool.io and readthedocs (obsolete))
Testing / CI / CD GitHub Actions No (tests exist) GitHub Actions
GitHub Stars 65 17 84
Static Analysis Yes (Flake8) No No
Packaging pip pip deb, rpm, pip
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 (tests/test_op_sql.py) No Yes (tarantool/connection.py)
Interactive transactions Yes No No (issue #163)
Varbinary support Yes (in MP_BIN fields) No Yes
UUID support Yes No No
Decimal support Yes No No
EXT_ERROR support Yes No No
Datetime support Yes No No
box.session.push() responses Yes (see push_subscribe option and docs/pushes.rst) No No
Session settings No No No
Graceful shutdown No No No
IPROTO_ID (feature discovering) Yes No No
Support CRUD No No No
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
Found what you were looking for?
Feedback