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

Uploaded PyPy Windows x86-64

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

Uploaded PyPy Windows x86-64

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

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.7.17-cp312-cp312-win_amd64.whl (229.4 kB view details)

Uploaded CPython 3.12 Windows x86-64

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

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.7.17-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.17-cp310-cp310-win_amd64.whl (232.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.7.17-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.7.17-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for asyncdb-2.7.17-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 2a0a4461438ad1a738a0dbe49cc7da2daedc68d90e4a4e02996bbf08b7bd3c89
MD5 beba2753c83596f85dfae395c26a9a0a
BLAKE2b-256 471ee8c0b1a47d3080322a0238a6c9a5a7a67737d74826518d3331daae761b83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.17-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 ee620dcd60973683fd3629683bf9996b29b1ecf96cc2efa08ffc069f80a96489
MD5 1d88049e8649071d213d74154eb08a04
BLAKE2b-256 12c0370faac0ed3487ca05008e7187f1b255e3b1b561be50bc51cde240f3f17c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.17-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.17-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6e1cb2657c8491fa103c5bfe104c4fd8fab833864d3c7ed08116803af827df4f
MD5 54d766a01631d63345968e266b4d47a5
BLAKE2b-256 6b09e1660332703e28ba2afbf063e7aefe6de16078661678be2309f83291f05d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.17-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 229.4 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.17-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 80c8fbe7fd78c7253fda51416bb8443be3c15e83dd743c856cf1b2c1f07358a5
MD5 ce23d80aa8cd93b7b6de84acfd76d995
BLAKE2b-256 88d4709f50c87bf0e6d94626561e4abcdffe269c39fa6aabfa14429ea6108ec2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.17-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6b4669da0ca953924e75af83afa13e20e58a7f3eb10eff6639a0d069cc700c2d
MD5 15753de80fa2da1cea1690fb39426fab
BLAKE2b-256 4afcb28f9a1dc36052f977b681335027ef9b1ffe92ad42c68f2508206b0acb4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.17-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.17-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a274b9578c27d5f79fb22541a82f288459b65f327f8f65d301972ffbd549fa34
MD5 563e2b6f28e1bedb90561e85f32a720c
BLAKE2b-256 9eecae66c94c909eaa02f5e94df848fa8a6d585b65d24b6eede55797b4c3920a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.17-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8d510a0ee900968d2adc26fe6d2a41171c2a490342acd6680eb0eb6c122cc200
MD5 484b7fa5ac9073880312360280d60905
BLAKE2b-256 f53fb5a35e4a8e724d3e3cd9b6aaace21856d49d1dcaf5bf6390f00f1ffb4835

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.17-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 232.0 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.17-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c3417a1fe8fa1f95974786814f10a25f8595f80c086628ed4008a81a2c74f438
MD5 e0edc1cf442418f9ca1bb6a486dbae1e
BLAKE2b-256 314fff789736191781f2bfb182bd6f78d15979e20c2cf03ae51109fe74adae2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 da993dbb013e0b119bc51ad3772e8cec43d812fec8a6844e05a34adb18951e53
MD5 5c96f43162cecb3e7827a823ac515282
BLAKE2b-256 f43d87cde40fe7b700beb839aa87dfee34499ede8f05fbf0184de5a9def23d85

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.7.17-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.17-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4be42c6d7ef42a0cc6ea1def726c73ba768f8f9827d3f3e9521472958f6360a2
MD5 95f91df5493756872e9a62af2298cbf3
BLAKE2b-256 997788f6c674fd28b791aa48d3c1d4e8bdb20c5512d1346c7b5ba0bd8a5fa9fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.7.17-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c421af2c5f362480a32f24c17080808a12daa579ab6a158f571ef0a02375195e
MD5 c210a81e0c462a0905dd1a641a57fd17
BLAKE2b-256 0bae241e53e2cc8278be45ac301d4772a0b35672393265c99a79bdaff87b0fd6

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