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

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

Uploaded PyPy Windows x86-64

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

Uploaded PyPy Windows x86-64

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

Uploaded CPython 3.13 Windows x86-64

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

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.8.4-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.4-cp311-cp311-win_amd64.whl (235.6 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.8.4-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.4-cp310-cp310-win_amd64.whl (235.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.8.4-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.4-cp39-cp39-win_amd64.whl (236.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.8.4-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.4-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for asyncdb-2.8.4-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 1692605ad51a12946c3e200ae3e7bc7a415d2d39d0c3846f9ca4cc21f3bb2835
MD5 5c4ad268744c6ec382a4bbad4279f6fa
BLAKE2b-256 d9ba7219efe3ee548132fb6f12194339d63f147c0f60c5776571be754ee8214d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.4-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 f0db2a6c6692d908b91f032b126a685e112c9930b64bd65d2c7ceb0c6de5191f
MD5 b90df989062548d97a53876509ff6be3
BLAKE2b-256 11e363bd51941dad2ab1a9ae03ad4010c06a3b155d811f7500fdfa1c78dae80c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.4-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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8e8e093a89ed0e44d7e7119dc56366d163fe80e463d5d5742729f77f689a1125
MD5 6f4808c43b0c344612cfd04a63d92921
BLAKE2b-256 9c576a9ee64e63b7e59fe10d8266aa426e3649ab8b92d1a36ad0e391cf5c32a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.4-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.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e47b96ad3d75885673a05c617f3add3ac3af2cbb555a97e5b53fa75b8634bf14
MD5 14a3e521f0aad7440e2929e53119c994
BLAKE2b-256 293d6c1466903bd451e91a548315a68755365988dd6cdb3f0f80b71959cc79e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e36c2616a87b7da611bc9f2b6693589a62a2ac705de26152302f552135ab7d5f
MD5 704dac3d4bb080d1b40dce4ceca95462
BLAKE2b-256 2495a319ee949476beeea7c1ad335a030122eb05e6f077a7c0b72e0e488964d3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.4-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.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7339d10fd4ffd777408049082e6c1289cb0c4b6e9c793979c1d4987fb0fe7b09
MD5 fb6cb038c75a7a34acfe1894d51e83af
BLAKE2b-256 a08f4b821a7db76265e7363a89b364dd9d6333197a73c4323e67b3784dd9a30c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9d3286d4d42f61a805b8e1a355b67066039fcbeed87779241b1164c1fb2932b7
MD5 66926880758b64cd72436f85f0adf6b5
BLAKE2b-256 e6ddd163876a637f68a5c70106a1787064006320919f2ef7150af1ac5d2fa9fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.4-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.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a1eeb54f3c2d4cc81d7e770c8d383181ff2c0764b9c2e1795af0fc660d5b9694
MD5 677c4acd6d7c4f5a9f493c8eb76cd8b9
BLAKE2b-256 ab1966e12e399a779d3aebc5aaf4299d524d4c9bf8ba00716bdc2d1270026742

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 92ebc8f908fad2895d55474243509b0fb62b746cc825b3a5ae92ff1ff4fe0db3
MD5 ebf8ade323b5da51752ca21d87ef829b
BLAKE2b-256 e3b40cde6bc914bdb291ba5b8ce39d4f7df6eae6046e06919d7ffbdeebee60ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.4-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.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b18e29301f6757ebf357ca36da62a490a6d6b49e1cede001312df553f4595103
MD5 625f09b1e6a0fd9bbcf65047894498a8
BLAKE2b-256 e563a448ff8189846b3ac4cb4c1fb05c0a1ca1c0f587e1b33ddff3e81d9d9157

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c4f669beb74a77a97539a8fe62945e5279935bb15bf15c2faf2d6e23cedd2845
MD5 d8f0e509649486e464637f6b4c32a36f
BLAKE2b-256 cc1264a81f2b2969168b1768e201811737199c77659a389338834eb4049327a9

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