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

Uploaded PyPy Windows x86-64

asyncdb-2.9.1-pp39-pypy39_pp73-win_amd64.whl (240.6 kB view details)

Uploaded PyPy Windows x86-64

asyncdb-2.9.1-cp313-cp313-win_amd64.whl (245.7 kB view details)

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.9.1-cp312-cp312-win_amd64.whl (246.6 kB view details)

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.9.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (924.9 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.1-cp311-cp311-win_amd64.whl (249.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (853.3 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.1-cp310-cp310-win_amd64.whl (248.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (793.5 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.1-cp39-cp39-win_amd64.whl (249.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (796.4 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.1-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 765006b5a21f8a998c1fc5ec658787e6c89dbad1519b5bb13e85be9040bcbe98
MD5 f43e6ca4826278262f2ad7fedb582fa4
BLAKE2b-256 fadfc5931e731655b067a698548503890ebebdc7a56c39b94083c525b26aeb5f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.1-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 6408f546eff8e93160f1c586b29816f78dcd2791a629671d3b53b488fbf42bc8
MD5 9135ae0d7b59ead83b5bc54d856c51b9
BLAKE2b-256 294d4b8521d9fb0bbc5ab6a145f3d60de157baf88f22c33d86d4ce7722e7f711

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 245.7 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.9.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 97f1479109d095f766125e49bb7404ce987bdb5bf43376e223efb834fe6781bf
MD5 2a9d2a5b1dbf9214894952cfc2744972
BLAKE2b-256 1a327ffdfc308c7853e00abc034a5a2a326278a56edeeb69a7688ea2696249bc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 246.6 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.9.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 599486cf31734ab6554c2a955a411e14e30731c5e242ca6f2572c5f3c8d576ee
MD5 7782e601247aca88fc65a965e66a678b
BLAKE2b-256 a086bc75f9529eb244c2900f24249cd2f106d727b8401546f0990ded43667d27

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b766320c73c11d0d4ea3af2b9577583fb45643f18c1b3e87918e85bab8c91301
MD5 6e51a7bda9071037cc323deb3c56847f
BLAKE2b-256 0e2c581482128a61022fd60a41e2291b993bec182fcd9a971abfd5af3798c0dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 249.0 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.9.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2c572284606cb585319e56e107ddd2012ccf0d1fb854ae78c5146ab79c6445e9
MD5 e631185640ea95989a3e60a606544e83
BLAKE2b-256 18cc7047de4d310342a871e8d39612148c501e88f390576b4860e14e9c09a6c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d88ac9d19ed66aea4f60c59983479a0d70fee4aff67deb1f8218eb7e53a445ac
MD5 a30ca0dd010890364f2564979874444d
BLAKE2b-256 21e865f04aecae203cebbb15c8fd80539265678d78779ebc81497b38cdb05705

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 248.5 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.9.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2f315d97cff5d1051a4fb54b41f3669f7547334fca517bdb7ae04c7801636852
MD5 7bb335f0db8533d8d0cd54b50c591486
BLAKE2b-256 edbc2a1167ecfdf11bad2752c8b784685eb3554c356eddd4ac2ca29287d076ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e60d93e4c70fa422400df28ec0e2965c65cb41e622683bdaf15cd06f0361ad3c
MD5 5d5127152fbcf52c53914543afb107e8
BLAKE2b-256 0a1620cbc00328a8dd9ff800d6c49a8944f3b4fecf5f9a859bb8db34627f3d16

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 249.3 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.9.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4c4660bfa5f9a8c78ee4b281ccec0c930d47b72f2d36e8fa33595c26f25b27e2
MD5 28dd490c688985c72292e1ecf334bae1
BLAKE2b-256 43e919e81e405e626848696bfdb61ec45f3e75c629e19892f2681a6db7ccec21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e236be25d23953823f24d2c6082c3282db317ce3d2b9f429bd871b29cfecc665
MD5 d31deed0ccc697411aa596ac2ce681e5
BLAKE2b-256 4f475dec11cc5132aeaa54b3c7af2c092c8fb8757fabe4208dd23ebee9ee02ea

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