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.11.7-cp313-cp313-win_amd64.whl (255.4 kB view details)

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.11.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (948.4 kB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

asyncdb-2.11.7-cp312-cp312-win_amd64.whl (256.7 kB view details)

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.11.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (954.6 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

asyncdb-2.11.7-cp311-cp311-win_amd64.whl (258.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.11.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (966.3 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

asyncdb-2.11.7-cp310-cp310-win_amd64.whl (258.5 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.11.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (890.2 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

File details

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

File metadata

  • Download URL: asyncdb-2.11.7-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 255.4 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for asyncdb-2.11.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 827a4b1ddeada5fc9f7ca12e14512deb08f665dca010a242210e38fa23463397
MD5 b76b815c2bbb85b3c59fccfbf1acaae3
BLAKE2b-256 b431dfeb850b75f22d476c0819e3ad2c2a5163bf595f7586154d3a13ab480228

See more details on using hashes here.

File details

Details for the file asyncdb-2.11.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for asyncdb-2.11.7-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3a1dced8b784ccadb893fde57fabb9ed0ba013a3f7cb7055b87ee362cccf5313
MD5 84953731b08ca771e50e154b877b5a1e
BLAKE2b-256 040d64beea0091687695f04af2127271c3ef410b198fbf75b28765b50486ccc1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.11.7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 256.7 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for asyncdb-2.11.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 fe55ed2ca5431fa3a7a3f9d048b11dfddc5eb90ea990f36a3bdb5bb4e541db35
MD5 b8996d6a30467ede709d243c2d074de7
BLAKE2b-256 3b275d702669c87d5dbfb0a1545007384f9642694937cf0099d50868b87f8c37

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.11.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 19198356d0288d112aa4f8691f03229b5628ecfd6baa08a438e34b0b00daca77
MD5 20fb5950d511d8f39b38fbacb1370c84
BLAKE2b-256 95318a9a3e18b6611817d03112f9b8d9d7d8f8d0a9b19f866cc751ca8a388b10

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.11.7-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 258.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for asyncdb-2.11.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 18579b8feaf1f350c99fa65fef43294b89e60267a0f00e087cd0f4ccfd9585c4
MD5 34e475c8e117c8f123692ad8c718f3b4
BLAKE2b-256 faa5874380720c4a19e484059bcab3584b74c86b3880d2568c8328537be0b83c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.11.7-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e1a4e664bdf99d412b369bf7119404706542fbd340569d738249e54094313c5f
MD5 babab9049ddc09571cf25fbc6c20d4f3
BLAKE2b-256 d1a5410ebf64fbbbb467ee809eb253b7c665f64d35bec9788ff622333572d526

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.11.7-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 258.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for asyncdb-2.11.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5e379995f21c1b10877efdf4e25ac49c248b2282aca859d361dd879fd2780bf2
MD5 377eb691eb158fe4332313469438e8c6
BLAKE2b-256 46d4017bd8ff842a00536557fcadf107cd34d9b1b04f1a59d05dad2b3d0041fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.11.7-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 72548ed4dc66ce5b834dfadee5f3aa04635ebe1193c455bd554eaaaee99ada65
MD5 558e7aa87cc209fb4e08d70e0bca31b7
BLAKE2b-256 836658595684225a80f54554b30f75aedf23d3a8b95723b4c4274da2a7542839

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page