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

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

Uploaded PyPy Windows x86-64

asyncdb-2.9.4-pp39-pypy39_pp73-win_amd64.whl (242.8 kB view details)

Uploaded PyPy Windows x86-64

asyncdb-2.9.4-cp313-cp313-win_amd64.whl (248.0 kB view details)

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.9.4-cp312-cp312-win_amd64.whl (248.9 kB view details)

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.9.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (927.1 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.4-cp311-cp311-win_amd64.whl (251.2 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.9.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (855.5 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.4-cp310-cp310-win_amd64.whl (250.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (795.7 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.4-cp39-cp39-win_amd64.whl (251.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.9.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (798.6 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.4-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 3543421b8e9b8a95fb74c45248606844ce427c066feb1df572be582a8c321b80
MD5 bf0861babc3e167a2d3398ff9bd8ca6b
BLAKE2b-256 34adfd6d842e8ed616340363ac461aa7bdc70a44373e2b5dad5f0748ea3f8d0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.4-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 2b849041092ad42c862f41ec00b6541dff48e7fe9dcba63c96e4975e87a3b079
MD5 476c5d5fb32fd34abc760a0eeb24a3d1
BLAKE2b-256 3ea29f7d58a8d694863e6a4fb8fc6f50ef675160627a3a98e64f9fe59d6cdabd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 248.0 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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 fe620a2d5aafc97da9df61d84c5e8e0f03b6e18bd10c9966e7c12ea23625c8ba
MD5 834cf186c9ae108478c995bbf253177e
BLAKE2b-256 309f591dd1cd1088e37bdf70827ffee24cca470d33c81985110d1a7d40d4d8f6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 248.9 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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c3d72ff3570f7546733ee46f7c1c233501ef5ce925cce86ac6122afe9ca69306
MD5 f40a29b43b1fda2b2a54b89109aea7a2
BLAKE2b-256 16b9514c355c43ba2a412e06ac2c68644f35429ce2f456117bb486e5bedbec2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6c4b8c2a10c0b64a5ebf83c3f51598764d0d6212232276e4129def6f5348fcb9
MD5 95f670504efa86896bc18991e03896e3
BLAKE2b-256 ac9e824622a575521b1cffacc56ccf8a21dd8cab365d0032db66127d68074596

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 251.2 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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d305365dc5d803187d3d2572300634a8d3c0c2dc6f5bdd8ae6ba04f205e9bfd8
MD5 05a3a21f812e5fe65ead694748a16298
BLAKE2b-256 00ae5c70ecbb94f69bf5133cb5ad771bb79f4269351e3cd2ee0a284e72400f3c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e1ac2804978431adf4466ab6e8e4606c31aa056a4b204fbc7e015be892c2a5d1
MD5 9a0b346cc5dc053981543e84d72840f0
BLAKE2b-256 0c368e5d7c830e319d35568239c9ece58512b64efa6da914bc40cf8567f085a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 250.7 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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 67f3346df51a1acf78895c6a6ad4aa166901932acbbb99aba165f3326295e18d
MD5 5d0af86096c578db7705974ab404c5b1
BLAKE2b-256 fdcaf1002ec9674a61571dbf7c4eb647e1505aefd725a9faff847a8c27ffe205

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fbaa42db44160c722bd980445e9165d8426dba0a3732298116d0f2051f8127da
MD5 fec65be00c2c814a686af96f4761e8ed
BLAKE2b-256 4e278b718d192b7b72b745e0f5df759710ca0bb3305d862a2bddbaf89a6551d8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 251.5 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.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 975d995e704d538250e517a133e965e534661f417ecf8ba68a9e98fd77935f98
MD5 693e31774ab1f3374f9b305ca43be01b
BLAKE2b-256 edde2b7873f4020314ff9b5814f7ba64c0a24e344869a2a20463a4b7a6b94c03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 015cffac36815a542aacba2fddfbdc12252204801a40447025b81c8f82033cd0
MD5 60136e15b4e9f24769445f2ae18475e8
BLAKE2b-256 83c855db7c47289d3ccf415b5f9e0ebe0c7883f90e6084eb03b5dd13ea2cb42a

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