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

This version

2.8.2

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.8.2-pp310-pypy310_pp73-win_amd64.whl (224.4 kB view details)

Uploaded PyPy Windows x86-64

asyncdb-2.8.2-pp39-pypy39_pp73-win_amd64.whl (224.4 kB view details)

Uploaded PyPy Windows x86-64

asyncdb-2.8.2-cp313-cp313-win_amd64.whl (229.5 kB view details)

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.8.2-cp312-cp312-win_amd64.whl (230.4 kB view details)

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (908.7 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

asyncdb-2.8.2-cp311-cp311-win_amd64.whl (232.8 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (837.1 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

asyncdb-2.8.2-cp310-cp310-win_amd64.whl (232.3 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (777.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

asyncdb-2.8.2-cp39-cp39-win_amd64.whl (233.1 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (780.2 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.2-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 79e559ea66776ffb24d9e6e819ff4f2fcd5364a472a63c5ab96f29c1f8feb7ac
MD5 0581ad5370fb5a72dbf27c08ccabe2e9
BLAKE2b-256 7051b259f86801b223db1abb3a9db72ee68693e496a2dc9875f0b6926755aaf0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.2-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 e82ddf4738ab082b4f24c1ba73a355f5715632ad1ab81eab4378453d2c8d101f
MD5 15e90bc34d662392b5663ed33f62e9b2
BLAKE2b-256 b26310cb552e3a29032e3bd899faaff25feb4dadf68ac84141eb0991fdfccb4b

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.8.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d4b8d58cf3449aa3cf37669201dbb1647d5f3d81273f42423e903f630d24ae43
MD5 f1dc6cb7e0e3c96f191be538dc5c017d
BLAKE2b-256 939240ffc7ac3b7558197d16a69e149c6356208bd32d346db836a93eaf2a23f4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.8.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 af6b364a924fafbe872a352f87c4728575463c687725fa27c51fde40a9e8b02d
MD5 7524e1cb5499355b744d343e9651b3a9
BLAKE2b-256 ffe287aca7e516d2577adb971cdc33cffa70860c5c055d4ce4e0d01594c1bff5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 95801e7ac081685cda7bf29edbfd067495e160fba5adddc92e1d46604883d555
MD5 c3dec8a2f32cff376eff88e4b6f3d7ff
BLAKE2b-256 04c9eae365f406de75a45177754064f41beb71284da13a6d37019ae082106ae9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.8.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 aa8d51be9fbd7aa2a8b3feb1c494aa213fcf0a9c1d65c5cee09e1bd654576789
MD5 4add6b628bf671ee38c5b9982e362757
BLAKE2b-256 752cf333f03bcf87c7585756b9f6e33128edd22732099d37ea8541ff6b5461b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d7c6f688c6550567924a7e4f34efebef530341c8fedd19e26e0a4fe2d1dff51e
MD5 4adeeb0f1947a025dfc0a125b62b6c79
BLAKE2b-256 72fb2871c6526daabaedd5a5b911f9ff96f96337f3c2041ac4f220a1ef66208c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.8.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 23ca84b0bd306d747f0153036a2665c4d94db5015d4b695b39ee34a80aa39c5f
MD5 0b763c9e52389a20d1779b8e28b8d4fe
BLAKE2b-256 e74f093f322824f228cefab8b3b0130b23c597e84c3f93b0b4072c0a0e691874

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3ef73fdef22eb4a9d1287d3722537e114bb30d48c2ddcc2069d2944fb9c10696
MD5 42cae9175a9d1fa160544a9b88290915
BLAKE2b-256 4f7be1130c55722ee214f21e2366ff4be07c70d155450daaee7fdb6ed4f9f907

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.8.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3a31831186f4fe5b0e03cfa7436c95463e52d169f98810dc1c500e3f34ed504f
MD5 3377890d413e0fb0f2654c69610a1814
BLAKE2b-256 870577570916d6c1a5710e0710e25111857a72eca9f62962525c514b9c9af2db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d03ffd1c00fa73e95904a3b6460165d447a37607f140656f465600d98ab2af2f
MD5 cd6b919c9d3617978ddeff92bab3ea4d
BLAKE2b-256 fff797899a54d5df316baba8fd891c59b1db8d0ac26c19f3008ae6a9c45db995

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