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 and 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 with a subset of drivers (connectors) for accessing different databases and data sources for data interaction. The main goal of AsyncDB is to use 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 and pymongo)
  • SQLAlchemy (requires sqlalchemy async (+3.14))
  • Oracle (requires oracledb)

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)
  • oracle: oracle (oracledb)

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.9.7

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

Uploaded PyPy Windows x86-64

asyncdb-2.9.7-pp39-pypy39_pp73-win_amd64.whl (243.0 kB view details)

Uploaded PyPy Windows x86-64

asyncdb-2.9.7-cp313-cp313-win_amd64.whl (248.1 kB view details)

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.9.7-cp312-cp312-win_amd64.whl (249.0 kB view details)

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.9.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (927.2 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.7-cp311-cp311-win_amd64.whl (251.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.9.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (855.6 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.7-cp310-cp310-win_amd64.whl (250.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.9.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (795.8 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.7-cp39-cp39-win_amd64.whl (251.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.9.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (798.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.7-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d943fd7d85e548127aea7f28f57fe8b196e9e6db09b51c4168888d3aeb717507
MD5 f4ed8d90357b82885e4a07a31f4b6fae
BLAKE2b-256 de73c1131eb001ec77f38624ecdf0c766fcaeae23c5f22c11fbbce7ca7eeac74

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.7-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 37796ba9bbcb237f3037ccaa0047a2a8b7034d313cd4c95d226cc1b7db741826
MD5 00cc2c36bb825be3514180d035958e61
BLAKE2b-256 44273755cb2efc3d1aeae54047e7de11d755672096de472462f6f8b094819417

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.9.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ebc3a9d337ae9a38ac8e6244eafc57eb6092cea94e8d3b944850430dbb9539e2
MD5 0ea69d3af55fc483b867fb734b6f9902
BLAKE2b-256 43cd7f002c47a39c9afd836a9f1ec811fb18850adfe7fd2c9a95704bf72b4e56

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.9.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 19a03a06d4b321e7183e7658209b688a82a466bcd97cdc28fb86b1478d4c5704
MD5 4941d67f4a68fb730dc5f3f2881f8bc5
BLAKE2b-256 bb120c496192e0a219837386aad6edc6ae92581367e363f1a3226117f39caccb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eca03561307634b52c974683c10fc6371bc28d148e53cbcbc41ea2529c6e9e3c
MD5 24707e144221915cbd764d56fbde6628
BLAKE2b-256 a8731531bb56a840094aa8e8e96c1277fbc47c9d0fd6b1f40748bda42794d4d3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.9.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 289901211078e7caffc3227c721595cdb468c6493669f3ce2d08c563e8e55db7
MD5 f8b2f392746d7d47776fa2c939e6ee26
BLAKE2b-256 78e479a89e76d9924b31d3d5d6f6a430e72b1a2b5d73a7cc3005cba50e77cd4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4275db92aef6e08af948b5c02b00179b5407a95800ef9bbcc0095f3a0cd0a852
MD5 013de40d6e3054e4a29537924722bfda
BLAKE2b-256 708b0c5a5e7ff03d8f2bed88a5cf273b2edcbb5eb04509830c4b61df472f76a2

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.9.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7d909e5391313e2887af744ed612b468c38eed690f46c2488a5bbf291d8cb6e1
MD5 1ed345e699e554e87964560fbc3489b1
BLAKE2b-256 196f0b96393fcfa0e542503f66b32bc7e23ed1c8f53f9d6895ff4bc178641c00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28d4ae15ed37a90cd4e257bd098292985453749ec87f9c7242f5a8148ff41c05
MD5 dcbee2d637ef54627049d7b5fdabe396
BLAKE2b-256 205b6214dc0d1fb7876b507fe48f808bf60efe2d15798e828c1c5ca2bbede4aa

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.9.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ffb715f2cc72fccbeaee841d11d8b189329dc161a7e4e45ef59a686754fee2d2
MD5 11b8d8daef8a16a386dae37d206ac3fa
BLAKE2b-256 9f5f2ef4b3f17af040bfca9a06ef83964dd0e1ddc98780c6be00a9b780b1600c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.7-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 82bc5d1b79d4fdef5cde154ec97312997dfb58a0129c031f4214c67d40d85189
MD5 cb51d162473a2bb8cdbe89cc8f3702aa
BLAKE2b-256 d009b04e8fb40374f75f2db1fa62847a02b66e42211eacb63fb29dee5ab9e4db

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