{"id":27294060,"url":"https://github.com/igorcoding/asynctnt","last_synced_at":"2025-04-11T22:45:44.181Z","repository":{"id":37922548,"uuid":"80914460","full_name":"igorcoding/asynctnt","owner":"igorcoding","description":"A fast Tarantool Database connector for Python/asyncio.","archived":false,"fork":false,"pushed_at":"2024-12-01T12:46:15.000Z","size":7529,"stargazers_count":81,"open_issues_count":6,"forks_count":9,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-03T19:06:27.416Z","etag":null,"topics":["async-python","asyncio","database-connector","high-performance","python","python3","tarantool"],"latest_commit_sha":null,"homepage":"https://igorcoding.github.io/asynctnt","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/igorcoding.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-04T11:17:07.000Z","updated_at":"2025-02-06T11:38:56.000Z","dependencies_parsed_at":"2024-05-09T11:45:52.895Z","dependency_job_id":"39a1c06d-a045-440f-b365-89d3f09d0d16","html_url":"https://github.com/igorcoding/asynctnt","commit_stats":{"total_commits":172,"total_committers":4,"mean_commits":43.0,"dds":"0.029069767441860517","last_synced_commit":"c6eebc97d93d5ef8a3a8fed6f759f91e1f3668d0"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorcoding%2Fasynctnt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorcoding%2Fasynctnt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorcoding%2Fasynctnt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/igorcoding%2Fasynctnt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/igorcoding","download_url":"https://codeload.github.com/igorcoding/asynctnt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248492961,"owners_count":21113160,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async-python","asyncio","database-connector","high-performance","python","python3","tarantool"],"created_at":"2025-04-11T22:45:43.467Z","updated_at":"2025-04-11T22:45:44.158Z","avatar_url":"https://github.com/igorcoding.png","language":"Python","readme":"# asynctnt\n\n[![Build](https://github.com/igorcoding/asynctnt/actions/workflows/actions.yaml/badge.svg?branch=master)](https://github.com/igorcoding/asynctnt/actions)\n[![PyPI](https://img.shields.io/pypi/v/asynctnt.svg)](https://pypi.python.org/pypi/asynctnt)\n[![Maintainability](https://api.codeclimate.com/v1/badges/6cec8adae280cda3e161/maintainability)](https://codeclimate.com/github/igorcoding/asynctnt/maintainability)\n\u003ca href=\"http://tarantool.org\"\u003e\n\t\u003cimg src=\"https://avatars2.githubusercontent.com/u/2344919?v=2\u0026s=250\" align=\"right\"\u003e\n\u003c/a\u003e\n\nasynctnt is a high-performance [Tarantool](https://tarantool.org/) database\nconnector library for Python/asyncio. It was highly inspired by\n[asyncpg](https://github.com/MagicStack/asyncpg) module.\n\nasynctnt requires Python 3.7 or later and is supported for Tarantool\nversions 1.10+.\n\n\n## Installation\nUse pip to install:\n```bash\n$ pip install asynctnt\n```\n\n\n## Documentation\n\nDocumentation is available [here](https://igorcoding.github.io/asynctnt).\n\n\n## Key features\n\n* Support for all the **basic requests** that Tarantool supports. This includes:\n  `insert`, `select`, `update`, `upsert`, `call`, `eval`, `execute`.\n* Full support for [SQL](https://www.tarantool.io/en/doc/latest/tutorials/sql_tutorial/),\n  including [prepared statements](https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_sql/prepare/).\n* Support for [interactive transaction](https://www.tarantool.io/en/doc/latest/book/box/atomic/txn_mode_mvcc/) via Tarantool streams.\n* Support of `Decimal`, `UUID`,`datetime` types natively.\n* Support for [interval types](https://www.tarantool.io/en/doc/latest/reference/reference_lua/datetime/interval_object/).\n* Support for parsing [custom errors](https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_error/new/).\n* **Schema fetching** on connection establishment, so you can use spaces and\n  indexes names rather than their ids, and **auto refetching** if schema in\n  Tarantool is changed\n* **Auto reconnect**. If connection is lost for some reason - asynctnt will\n  start automatic reconnection procedure (with authorization and schema\n  fetching, of course).\n* Ability to use **dicts for tuples** with field names as keys in DML requests\n  (select, insert, replace, delete, update, upsert). This is possible only\n  if space.format is specified in Tarantool. Field names can also be used\n  in update operations instead of field numbers. Moreover, tuples are decoded\n  into the special structures that can act either as `tuple`s or by `dict`s with\n  the appropriate API.\n* All requests support specification of `timeout` value, so if request is\n  executed for too long, asyncio.TimeoutError is raised.\n\n\n## Basic Usage\n\nTarantool config:\n\n```lua\nbox.cfg {\n    listen = '127.0.0.1:3301'\n}\n\nbox.once('v1', function()\n    box.schema.user.grant('guest', 'read,write,execute', 'universe')\n\n    local s = box.schema.create_space('tester')\n    s:create_index('primary')\n    s:format({\n        { name = 'id', type = 'unsigned' },\n        { name = 'name', type = 'string' },\n        { name = 'uuid', type = 'uuid' },\n    })\nend)\n```\n\nPython code:\n\n```python\nimport uuid\nimport asyncio\nimport asynctnt\n\n\nasync def main():\n    conn = asynctnt.Connection(host='127.0.0.1', port=3301)\n    await conn.connect()\n\n    for i in range(1, 11):\n        await conn.insert('tester', [i, 'hello{}'.format(i), uuid.uuid4()])\n\n    data = await conn.select('tester', [])\n    tup = data[0]\n    print('tuple:', tup)\n    print(f'{tup[0]=}; {tup[\"id\"]=}')\n    print(f'{tup[1]=}; {tup[\"name\"]=}')\n    print(f'{tup[2]=}; {tup[\"uuid\"]=}')\n\n    await conn.disconnect()\n\n\nasyncio.run(main())\n```\n\nStdout:\n\n*(note that you can simultaneously access fields either by indices\nor by their names)*\n```\ntuple: \u003cTarantoolTuple id=1 name='hello1' uuid=UUID('ebbad14c-f78c-42e8-bd12-bfcc564443a6')\u003e\ntup[0]=1; tup[\"id\"]=1\ntup[1]='hello1'; tup[\"name\"]='hello1'\ntup[2]=UUID('ebbad14c-f78c-42e8-bd12-bfcc564443a6'); tup[\"uuid\"]=UUID('ebbad14c-f78c-42e8-bd12-bfcc564443a6')\n```\n\n## SQL\n\nTarantool 2.x brought out an SQL interface to the database. You can easily use it\nin `asynctnt`\n\n```lua\nbox.cfg {\n    listen = '127.0.0.1:3301'\n}\n\nbox.once('v1', function()\n    box.schema.user.grant('guest', 'read,write,execute', 'universe')\n\n    box.execute([[\n        create table users (\n            id int primary key,\n            name text\n        )\n    ]])\nend)\n```\n\n```python\nimport asyncio\nimport asynctnt\n\n\nasync def main():\n    conn = asynctnt.Connection(host='127.0.0.1', port=3301)\n    await conn.connect()\n\n    await conn.execute(\"insert into users (id, name) values (?, ?)\", [1, 'James Bond'])\n    await conn.execute(\"insert into users (id, name) values (?, ?)\", [2, 'Ethan Hunt'])\n    data = await conn.execute('select * from users')\n\n    for row in data:\n        print(row)\n\n    await conn.disconnect()\n\nasyncio.run(main())\n```\n\nStdout:\n```\n\u003cTarantoolTuple ID=1 NAME='James Bond'\u003e\n\u003cTarantoolTuple ID=2 NAME='Ethan Hunt'\u003e\n```\n\nMore about SQL features in asynctnt please refer to the [documentation](https://igorcoding.github.io/asynctnt/sql.html)\n\n## Performance\n\nTwo performance tests were conducted:\n1. `Seq` -- Sequentially calling 40k requests and measuring performance\n2. `Parallel` -- Sending 200k in 300 parallel coroutines\n\nOn all the benchmarks below `wal_mode = none`.\nTurning `uvloop` on has a massive effect on the performance, so it is recommended to use `asynctnt` with it\n\n**Benchmark environment**\n* MacBook Pro 2020\n* CPU: 2 GHz Quad-Core Intel Core i5\n* Memory: 16GB 3733 MHz LPDDR4X\n\nTarantool:\n```lua\nbox.cfg{wal_mode = 'none'}\n```\n\n|           |  Seq (uvloop=off) | Seq (uvloop=on) | Parallel (uvloop=off) | Parallel (uvloop=on) |\n|-----------|------------------:|----------------:|----------------------:|---------------------:|\n| `ping`    |          12940.93 |        19980.82 |              88341.95 |            215756.24 |\n| `call`    |          11586.38 |        18783.56 |              74651.40 |            137557.25 |\n| `eval`    |          10631.19 |        17040.57 |              61077.84 |            121542.42 |\n| `select`  |           9613.88 |        16718.97 |              61584.07 |            152526.21 |\n| `insert`  |          10077.10 |        16989.06 |              65594.82 |            135491.25 |\n| `update`  |          10832.16 |        16562.80 |              63003.31 |            121892.28 |\n| `execute` |          10431.75 |        16967.85 |              58377.81 |             96891.61 |\n\n\n## License\nasynctnt is developed and distributed under the Apache 2.0 license.\n\n\n## References\n1. [Tarantool](https://tarantool.org) - in-memory database and application server.\n2. [aiotarantool](https://github.com/shveenkov/aiotarantool) - alternative Python/asyncio connector\n3. [asynctnt-queue](https://github.com/igorcoding/asynctnt-queue) - bindings on top of `asynctnt` for [tarantool-queue](https://github.com/tarantool/queue)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorcoding%2Fasynctnt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Figorcoding%2Fasynctnt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Figorcoding%2Fasynctnt/lists"}