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

Uploaded PyPy Windows x86-64

asyncdb-2.7.14-pp39-pypy39_pp73-win_amd64.whl (224.1 kB view details)

Uploaded PyPy Windows x86-64

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

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.7.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (909.0 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.7.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (837.4 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.7.14-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.14-cp39-cp39-win_amd64.whl (232.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.7.14-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.14-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for asyncdb-2.7.14-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 e671ecc6362acc2aed98b23229c49f756f0ed6f0a054f941d2c04f17bf113342
MD5 87aa0f3345f5531d014c88f3456c3d4f
BLAKE2b-256 f78755d7d3b58d1ca19377cbeee387f2c6d66ab2f8cc43425fe05439ba3837dd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.14-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 1b44ca4a6588a6cbd5a2fe56d7913b7a2bf620aec038ef8e6fcfe6334bef4a52
MD5 50bc17346472b5e4d041b3733ac19b76
BLAKE2b-256 e4acf5f26de5d807ca65165955d690eb06b8044c32b5568872eaab15b849fa19

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.14-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.14-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 043e88d2bd4d34107cf1cf0d262d483628e8d2570f4c40ffb8fe3a0d8ec017a3
MD5 6ddf4d04dae3a7c012d5421b2e8a9dd4
BLAKE2b-256 2dbdfee02fed2ea2e3c8be51e34833280058f49d0b82a8e259dd03a3b4322f93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3bb37d669d10c9f776c6fe5df5b9544f19207ae30da7e3b46f0651dcf68714c2
MD5 d0fdac17f49b205e821571db2c6c0b8a
BLAKE2b-256 26b4cfbee2d225856018450d1cce22e33713e24b8347c74c5a12e4a82f7e23af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.14-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.14-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9db74effa12df43fd637f2ddd02de49bf1ef998b8f8ec773fd49eabfc2ce36aa
MD5 bfb1fc80b0e28a953ec2b25917087837
BLAKE2b-256 2cc1faea59fa99a5c2c13ee1fb0e5ddd0bd6f6f7a4ca2f999ee0d762ceedf44d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bedd3888c6f27410dc0a78e906973bd40c08ce1f696284e8304884732482b319
MD5 45720925c67af62f73073d8d2ea580f6
BLAKE2b-256 28d527e6c9f1c382d93dddb18009acb6a9975e22220095e8e17d264228ef2ca3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.14-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.14-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4d0fa9b69948254907877d7739622054082cb7558d6a47ccc1e6af9197628220
MD5 a6bcfad39c3d5d40fb3de03b08c327f8
BLAKE2b-256 0d038900b966fcda1b34f3c15da83da3970bc3acba12677df95a3eb7ce1bc02f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0e95b445de46ae244d713d097a47d2e4dff6dfa224c007aec13f9e6abb556c2f
MD5 fd44417c2b4bfcdcd8d7c50d80b77687
BLAKE2b-256 d1eace3e42b46a9f7404da601283656c6d3c9bc6d9749552ec25766a5871f55c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.14-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.14-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0962d66e624a8855089b689345635911250d06c9d3a4293c37b06dcedd426af4
MD5 0e3f87c6e8693a68f0d555f4bd68ebc8
BLAKE2b-256 cc53b0bb93fd3b7ba393e621ba629c2230164293d8893fb0abe0238cc9126ae6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cfa9518c87c601ada816e1df48511b89130550ea31cda265fd664009300830e3
MD5 6bb03abfcd24cdb456c43a5aceb6470c
BLAKE2b-256 946d6e5cc3e9944a5d1efd4a4aff5682e5977fd319adba095f416d7d2f85dbbc

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