Python | Tarantool
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: 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
Found what you were looking for?
Feedback