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

Uploaded PyPy Windows x86-64

asyncdb-2.9.5-pp39-pypy39_pp73-win_amd64.whl (242.9 kB view details)

Uploaded PyPy Windows x86-64

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

Uploaded CPython 3.13 Windows x86-64

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

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.9.5-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.5-cp311-cp311-win_amd64.whl (251.2 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.9.5-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.5-cp310-cp310-win_amd64.whl (250.8 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.9.5-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.5-cp39-cp39-win_amd64.whl (251.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.9.5-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.5-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for asyncdb-2.9.5-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 5167e1ed1a901959eac347b99e4f532bd29717acd265fd6d43898277da8171c3
MD5 4560ef0d48c8a96a83e87a8ca078778e
BLAKE2b-256 bdd4fd57cdaef391043d2be2bda46912e1210628db6fe47ceb269070b51b7147

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.5-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 8fe904f8dfc1e2cc12f4a37dc3703236ee88bea5f732c12df16b1acf3ff9262e
MD5 9d214b262bc536118e0686d7e6dfc040
BLAKE2b-256 301a8aefb9338e4d4e7b5d28bf597becfe997e02a50f82552bf43244b478e400

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.5-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.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a1b06fed5c415723ac941b1b9d268c5b96595cbc798725143fc744de05eb50f2
MD5 ea44f20e6e5cd54d89be96a072145ee0
BLAKE2b-256 1eee2fd5974436c586c44c7c81c62073dde418427ea8c16e91753aeb5e10116c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.5-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.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2c9797905a332464d729f9ef102b794187056e0f5c1a35bc430620c7aa96f0e6
MD5 4b5f23f7ff0f0d2d62f1ff8d4029d45b
BLAKE2b-256 e54a6b564aa65b56e72caa12da49ceb9eefd276d8bbc18dde9026fde9c613fd7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b24f4174208602b15d005c1e68cc0ba51fb3365eb60427d556adb51b88d97280
MD5 a2b0a0b99b497da7c5b5bc19c0b07481
BLAKE2b-256 1179d5348029a87896eee8c9ad676dea5fe6d08d5b842aee771d1138a8f2f361

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.5-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.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 95306b8243ba125715d4c4274764380f73df74117af9f77b62105e08503a9dcb
MD5 f2b030201c16cd32184e8de977ccf09e
BLAKE2b-256 1cf7c06942f09aa120c0a401dad1f3e5023dc125749ca551315e2622c58101ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45eae480eecedb642b7c9847e13ad399c5dfe1d455ebf3706c66bcf0a64ce9b2
MD5 f7718ea9f3d0cf060f8a4561d32bc701
BLAKE2b-256 2f9259d9ebd188a224fe9d51b24fdd238b031bba5815ec6fb34a829d743f9bda

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 250.8 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.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 57d2f086a0f40fa045137d538b7d9337701dd55f5ca119ac1d2f6d71e283123c
MD5 671130109aec69e873fd0ce139517615
BLAKE2b-256 f3207b7fd9448baabeb60f2186aa3e49450799d7d383d752621706831a9711c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9664f69a5d135a87404d8b46ec656e158f760741e8cbcc762dec4cd6e50b27a
MD5 512ca896ac0481e9cd86c393c9e8d032
BLAKE2b-256 37804696b83320720543d77bfda86ae2c05c19a655833c3fb71bfd088849b117

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 251.6 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.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ed785b15723220e8265f4a86fc33dad1a0d6dab6e5163d7ff5d2a2cb1b6c39bf
MD5 7c6296999b66f9f9602b3f3f36f0c883
BLAKE2b-256 1aee1adeeada572dd50706720fba652d8601bc8c3f98f1a1e5083736d5849ac5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 33c74b9bd072ab07017bcfd133d49baa831401356224d8f7e8185b6bf1b0b08e
MD5 5909a69349b43a414830952594c96b8e
BLAKE2b-256 bc3661bc35458c52ef575eb6614f0a34e8c299ea5dc4141d80e8db3f06cc9011

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