Skip to main content

Library for Asynchronous data source connections Collection of asyncio drivers.

Project description

AsyncDB

AsyncDB is a collection of different Database Drivers using asyncio-based connections, binary-connectors (as asyncpg) but providing an abstraction layer to easily connect to different data sources, a high-level abstraction layer for various non-blocking database connectors, on other blocking connectors (like MS SQL Server) we are using ThreadPoolExecutors to run in a non-blocking manner.

Why AsyncDB?

The finality of AsyncDB is to provide us a subset of drivers (connectors) for accessing different databases and data sources for data interaction. The main goal of AsyncDB is using asyncio-based technologies.

Getting Started

Requirements

Python 3.9+

Installation

$ pip install asyncdb
---> 100%
Successfully installed asyncdb

Can also install only drivers required like:

$ pip install asyncdb[pg] # this install only asyncpg

Or install all supported drivers as:

$ pip install asyncdb[all]

Requirements

Currently AsyncDB supports the following databases:

  • PostgreSQL (supporting two different connectors: asyncpg or aiopg)
  • SQLite (requires aiosqlite)
  • mySQL/MariaDB (requires aiomysql and mysqlclient)
  • ODBC (using aioodbc)
  • JDBC(using JayDeBeApi and JPype)
  • RethinkDB (requires rethinkdb)
  • Redis (requires aioredis)
  • Memcache (requires aiomcache)
  • MS SQL Server (non-asyncio using freeTDS and pymssql)
  • Apache Cassandra (requires official cassandra driver)
  • InfluxDB (using influxdb)
  • CouchBase (using aiocouch)
  • MongoDB (using motor)
  • SQLAlchemy (requires sqlalchemy async (+3.14))

Quick Tutorial

from asyncdb import AsyncDB

db = AsyncDB('pg', dsn='postgres://user:password@localhost:5432/database')

# Or you can also passing a dictionary with parameters like:
params = {
    "user": "user",
    "password": "password",
    "host": "localhost",
    "port": "5432",
    "database": "database",
    "DEBUG": True,
}
db = AsyncDB('pg', params=params)

async with await db.connection() as conn:
    result, error = await conn.query('SELECT * FROM test')

And that's it!, we are using the same methods on all drivers, maintaining a consistent interface between all of them, facilitating the re-use of the same code for different databases.

Every Driver has a simple name to call it:

  • pg: AsyncPG (PostgreSQL)
  • postgres: aiopg (PostgreSQL)
  • mysql: aiomysql (mySQL)
  • influx: influxdb (InfluxDB)
  • redis: redis-py (Redis)
  • mcache: aiomcache (Memcache)
  • odbc: aiodbc (ODBC)

Future work:

  • Prometheus

Output Support

With Output Support results can be returned into a wide-range of variants:

from datamodel import BaseModel

class Point(BaseModel):
    col1: list
    col2: list
    col3: list

db = AsyncDB('pg', dsn='postgres://user:password@localhost:5432/database')
async with await d.connection() as conn:
    # changing output format to Pandas:
    conn.output_format('pandas')  # change output format to pandas
    result, error = await conn.query('SELECT * FROM test')
    conn.output_format('csv')  # change output format to CSV
    result, _ = await conn.query('SELECT TEST')
    conn.output_format('dataclass', model=Point)  # change output format to Dataclass Model
    result, _ = await conn.query('SELECT * FROM test')

Currently AsyncDB supports the following Output Formats:

  • CSV (comma-separated or parametrized)
  • JSON (using orjson)
  • iterable (returns a generator)
  • Recordset (Internal meta-Object for list of Records)
  • Pandas (a pandas Dataframe)
  • Datatable (Dt Dataframe)
  • Dataclass (exporting data to a dataclass with -optionally- passing Dataclass instance)
  • PySpark Dataframe

And others to come:

  • Apache Arrow (using pyarrow)
  • Polars (Using Python polars)
  • Dask Dataframe

Contribution guidelines

Please have a look at the Contribution Guide

  • Writing tests
  • Code review

Who do I talk to?

  • Repo owner or admin
  • Other community or team contact

License

AsyncDB is copyright of Jesus Lara (https://phenobarbital.info) and is licensed under BSD. I am providing code in this repository under an open source licenses, remember, this is my personal repository; the license that you receive is from me and not from my employeer.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

asyncdb-2.7.18-pp310-pypy310_pp73-win_amd64.whl (224.0 kB view details)

Uploaded PyPy Windows x86-64

asyncdb-2.7.18-pp39-pypy39_pp73-win_amd64.whl (224.0 kB view details)

Uploaded PyPy Windows x86-64

asyncdb-2.7.18-cp313-cp313-win_amd64.whl (228.7 kB view details)

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.7.18-cp312-cp312-win_amd64.whl (229.5 kB view details)

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.7.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (908.9 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

asyncdb-2.7.18-cp311-cp311-win_amd64.whl (232.5 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.7.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (837.3 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

asyncdb-2.7.18-cp310-cp310-win_amd64.whl (232.1 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.7.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (777.4 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

asyncdb-2.7.18-cp39-cp39-win_amd64.whl (232.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.7.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (780.3 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

File details

Details for the file asyncdb-2.7.18-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for asyncdb-2.7.18-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 a1ba7699261ab3282244cffbaca606808e2747a284eb101707002d6f8d0816a0
MD5 a0480e31a14eb72e27de6329f85517f9
BLAKE2b-256 e06dd27d8ba53804801f9619d407b1af20f944c86b573efe466e57b16795f93b

See more details on using hashes here.

File details

Details for the file asyncdb-2.7.18-pp39-pypy39_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for asyncdb-2.7.18-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 a464a078e417d7c31fa069ee52a4084a5eec1b511ba891a3bed621365fd30a48
MD5 a09e4b8bc6ea7dedcf04cc9469d5fed5
BLAKE2b-256 25285bd1747ad68889435a4b0bca817852b230743baee1406fe362c9abeec406

See more details on using hashes here.

File details

Details for the file asyncdb-2.7.18-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: asyncdb-2.7.18-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 228.7 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for asyncdb-2.7.18-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 87a78aa703be4960014d276a4f92ac2bc2ac8cfb224ae6f16bd3911fcf498b1e
MD5 58b59fbd6be0ca05ee63bf5d0a9289c7
BLAKE2b-256 d19d93161bd92fcfcac240bcfe2c1939140b35b5a373207cf3aac21f79e4bc38

See more details on using hashes here.

File details

Details for the file asyncdb-2.7.18-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: asyncdb-2.7.18-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 229.5 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for asyncdb-2.7.18-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 d3f7615c0d72c0ea073808db19a39affd0128850f18bec9503e56b845c97c818
MD5 90226661223688de873e761cbb4ebb64
BLAKE2b-256 107302378370ccf5ab29f3da89dba10cf20e32d06d50e489743947f74c0fc07a

See more details on using hashes here.

File details

Details for the file asyncdb-2.7.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for asyncdb-2.7.18-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6dffc3453ec09ba6697d6bc98e317779b925f36b58017c03ded32123c34c3fb6
MD5 550c51c82e14b2f2fc9d679a922f1fe3
BLAKE2b-256 9318bde72e3cf667f0070bb4e771537c11d6307548edf7e7a75f73ec23c7c767

See more details on using hashes here.

File details

Details for the file asyncdb-2.7.18-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: asyncdb-2.7.18-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 232.5 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for asyncdb-2.7.18-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 aba622622d7c5eb35497d799371f19556916de1eb3bf756da00fd21b8a21d05f
MD5 aaac3f84fc7908ab083668b8500e6b55
BLAKE2b-256 7f9bea3bdab70e81a9fb661f21a7adaf57ed01d29b3e48ca11344a08e5ad6812

See more details on using hashes here.

File details

Details for the file asyncdb-2.7.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for asyncdb-2.7.18-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b7271eb3eaec7d98b38887b914a3f9811fde8c57e4469b879877a0b06efbbf9c
MD5 d939088d60d0a1f8d4b9081a6ebc2e1d
BLAKE2b-256 bd312f42b3bf6f589131c6b0fa5dc8d27417a1725f61d5dc512a2aa35edb71d5

See more details on using hashes here.

File details

Details for the file asyncdb-2.7.18-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: asyncdb-2.7.18-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 232.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for asyncdb-2.7.18-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d906d24898fcf705c1818f0700c68f3f6595bbdcf57fc236e388d8db1ca204af
MD5 2fee5ff5a1d1198bdcf260e2a29e2231
BLAKE2b-256 a9daaf8a17a915e922a12113c8912941462aceabbcba2757938a47f186095312

See more details on using hashes here.

File details

Details for the file asyncdb-2.7.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for asyncdb-2.7.18-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b82411e17004ecbf79d3d0f444b296c149c4412c2a6a211d268dece2e6d865a1
MD5 7cf011b168a90dd61f7d7b3bbff38369
BLAKE2b-256 81a3c0515952fc38e0ae69cdfa1b987213a2111247935645e53fa03498df3a90

See more details on using hashes here.

File details

Details for the file asyncdb-2.7.18-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: asyncdb-2.7.18-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 232.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for asyncdb-2.7.18-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 faa9a9f8ff0b6a58bff49dab94957001664f6bb2f41330f6d1c140789d53d465
MD5 b98b776d53a5a91192fa7f53345e27bc
BLAKE2b-256 ff1a18ff0fbf74d939829ec18603774163793b1e43a119edaf8b3f077c94ee2f

See more details on using hashes here.

File details

Details for the file asyncdb-2.7.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for asyncdb-2.7.18-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e0c7256028cb8b417dfb1ca10dc058bcc301e871ceca6a8ea8bd3b667b625ff7
MD5 b452b44bd2df6913832c8f89ef1b678f
BLAKE2b-256 5fc0fb2a5983303be981a210dae1de4e4223e341282a467a0b0cd55ef5a2e9d1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page