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

Uploaded PyPy Windows x86-64

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

Uploaded PyPy Windows x86-64

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

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.7.16-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.16-cp311-cp311-win_amd64.whl (232.5 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.7.16-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.16-cp310-cp310-win_amd64.whl (232.1 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.7.16-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.16-cp39-cp39-win_amd64.whl (233.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.7.16-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.16-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for asyncdb-2.7.16-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d9f5abe09a85ab03d6512c029bdea77cb63b09440a473b0e0a8108c3c2498ca5
MD5 acf00bf048917053c1192c6b5d5bcc78
BLAKE2b-256 75f49adf6f8ac90fbd93711c9496ccc73792ae6aa6d5731cef288e9b3206a3ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.16-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 7eb4ee23193c4ee7fc3109b0e9cc0a6eda1b445be15919bb9bc74c3b717412dc
MD5 61eb18785be5b6e1d17f5dc32f984df6
BLAKE2b-256 b330bc2429691b47fb2c94f47a885dbb5f72798667f79b794d26b302ea9cc224

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.16-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.16-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 050219e57e12b1c4a65cd78111687a0fef71d68b91781d5bbd0cca3992051996
MD5 c1e7f23d8c840bece01d0b853717efae
BLAKE2b-256 197411c472fc17807239d79953ba37b25227a12acbe3680b7f040f67fd4c41a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.16-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5baec223c89a901011c951bc32f7bf90f7494b42daefe45ce56d7322fa338aa5
MD5 d3a6ced70f3a309bde59b7b1d0353923
BLAKE2b-256 41fa66bf208f00c6985e2661f0d9bc4e151b6fc3efec5de19a96a162807b98d0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.16-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.16-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bb51687e86e1e79d2d22f5dd526279d12dff90770aab2b7c97ed883654357392
MD5 8aa098cd22f819270a3ecd67b291139f
BLAKE2b-256 6ca582d2e44b4641eb8bf19c73f4374718ce81def16a72c64003a9a6d27100d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.16-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 daecf6666574a8b0afc692e8e848d9b38b67c5a1d85e1585b53f34f7171cefb4
MD5 0f8683212c9548bb0d876766ba4bb1d5
BLAKE2b-256 0270a00fa3defd4de8e5370188b39cb1e76c0a5d66c8aab88ee7fcd0093083c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.16-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.16-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7095b9b677fc5608809e6e74698720539fd8f2b14cef0f57044e5692c76ac8f7
MD5 e6b30997760b72ac8687501a7427ea03
BLAKE2b-256 63dbfbd61d840768c525889e88a4fb8fb062d6a557e9077d0acf7f05187935c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.16-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c7fd6187d7eb6f019e08c9b04c2f4e722cc8a819a4697adbac8ee393845dbdc8
MD5 574c9f96932f8341d83a63de745aad70
BLAKE2b-256 ba2779c15a39671c3a7407a349792f72876df7f0b200aabb31f7215bbba1b0f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.16-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 233.0 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.16-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 afea0850ef0864662b308b4394376eb88c07727d69a772855684911db7156a80
MD5 0758fc3f4a593396357613d4ab90e148
BLAKE2b-256 53841b3447fb5072afa4dffee6a3d04775afdc39559d66bbec095db2714ee8e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.16-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f0418a4ee234640f9afb7024b8707222270377b892948352564d02ca7afc2569
MD5 2cba4c35ddf3162e12897fbf4034c806
BLAKE2b-256 0a9db85ae3310bb7cd3e3131c3d5e91a9a1324753fcd721131dd7455a59a72c3

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