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

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

Uploaded PyPy Windows x86-64

asyncdb-2.8.3-pp39-pypy39_pp73-win_amd64.whl (227.3 kB view details)

Uploaded PyPy Windows x86-64

asyncdb-2.8.3-cp313-cp313-win_amd64.whl (232.4 kB view details)

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.8.3-cp312-cp312-win_amd64.whl (233.3 kB view details)

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.8.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (911.6 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

asyncdb-2.8.3-cp311-cp311-win_amd64.whl (235.6 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.8.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (840.0 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

asyncdb-2.8.3-cp310-cp310-win_amd64.whl (235.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.8.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (780.2 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

asyncdb-2.8.3-cp39-cp39-win_amd64.whl (236.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.8.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (783.0 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.3-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 eb21433bfc065662c95486f5b0fbf7a87802d89bcc03ec5339a81c5c8bc4ff86
MD5 b543f805763f90433c100ba0dbcf7ac6
BLAKE2b-256 c7565e2484ac1fc443c22a9250b676653ecf96e7a414ffde85de2f05baef4506

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.3-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 720f58cc5f85b894cf9a5c2d4e0ef2aecf8353f8fde148684899f187503c2412
MD5 2b4ac8c4eb888d0df30010f28b05bd1e
BLAKE2b-256 7482067306aa1379d32e59a543df3a5059941e2793307c0787cde9092b61b9ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 232.4 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c7bb94f5a58ad7d393b4c69612af373abfc445a03c6b8f2b65812e630aa1ab6f
MD5 729f3fd61a53045768cfbdb3e099dbfd
BLAKE2b-256 3c12bb4a72f8c267d6bf5191238a44f0d2a4940f4e0480dd006cdf47870b4f65

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 233.3 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c998f7f009579193ad48cab12390f7c56da9a59c1f55f2537fa448e67d6628d4
MD5 1d309840b9d56f8240e82533b03a5b79
BLAKE2b-256 ad9c756cf15fc8f78f1d8ee7717f74f835371a559404ee00744c4a56ca72a3f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1347824f4303ff65830a0f89c7775fcdd94f946e75a5ac0a007251ec134b85f9
MD5 869cfc3129611e031352a508eececf55
BLAKE2b-256 f9bdc701e7eac8a53d87bad946b30d73adad30713b79b74c6581cb7273faf07d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 235.6 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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 eaa5bea08eaa1b920d83c5e63a35efc60e76816139b2c6edb81317a02a2919a9
MD5 5c9dac3b6395267b0ece5c80b8e02015
BLAKE2b-256 a33c67f2cf8eee60a3f1a899ef1c56b359f37c0f9601883a1eaa3ef72a01c9a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 77445309af870aaec75af911bfaa148411ee8178472a6c4bb4778be44c40c390
MD5 aefb309efbd8df67b3d04c3773055298
BLAKE2b-256 5f98c2a686fe7488ae749122f3d637e413a011f4df0ec12637a592c605aa8588

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 235.2 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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b5f5393676c78c41f33b2a70cbdd024365ac7dcc891f33c1ddb18c824aa89b35
MD5 03c10e094caa9e155b0d09657cc2d071
BLAKE2b-256 36c82e00cfc863f93993866d61989b76c5e20adfef04f57e23b930be3335a430

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52effc515c8dced2a9efa4650d1849d0ec1af3e8b8ac93eda574647a0c8a82e1
MD5 be0e10609318ccbcd601cb15ba9e556c
BLAKE2b-256 3e7b728b49be9c2aaa2308cd4d25be31aca09e45401e3d842dfb215a4723ea5e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 236.0 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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0b847418b8b1bb0735aea093cdd0ad35d8fa696c53a0a482abb57137d2fbf741
MD5 db65ad42afd2e0f202a988c08a2cbdab
BLAKE2b-256 dfaab928819604c843e0fd3e50d639ac12f9b917fc6a408bdcc6b90d1fc6801c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 db88b9bab610e260329e7e3c6974fefbe144522da6d0f29aceea35da8c8b9b05
MD5 71de75fa1660454966a5730efd1f5013
BLAKE2b-256 ef18d068da39c958da07380f3b94ad90fcf2087c39e3f3c61f3c8a18e405ffb3

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