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

Uploaded CPython 3.13Windows x86-64

asyncdb-2.11.9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (949.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

asyncdb-2.11.9-cp312-cp312-win_amd64.whl (258.0 kB view details)

Uploaded CPython 3.12Windows x86-64

asyncdb-2.11.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (956.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

asyncdb-2.11.9-cp311-cp311-win_amd64.whl (260.3 kB view details)

Uploaded CPython 3.11Windows x86-64

asyncdb-2.11.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (967.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

asyncdb-2.11.9-cp310-cp310-win_amd64.whl (259.8 kB view details)

Uploaded CPython 3.10Windows x86-64

asyncdb-2.11.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (891.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.11.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 32baea3d53166810b1fc004e2d231c20ab6449100fef65af9280f3a72ca9486c
MD5 d2fb88c48765a88502382ac41ccb53ea
BLAKE2b-256 a5f8db8576e3bc48ab0b4489980060e7254797afb2c1f7886215e4a007eb16d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.11.9-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8cd7520526a8cf05b36fa559e40941a9957443976b8745385aa94258000c9c5a
MD5 04b3329d61cb596f24003b42fc0c0e6d
BLAKE2b-256 ac39303c76048784cec99931ccd0a4a63285b97d1ad2da5c20a829bec2bf9eb8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.11.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9749c0264fec6e19c5b62e3b35eef3ad23223cfbfcede886d57bea1a17712251
MD5 d3a1a05f46de5928711b9b6ac6ee19be
BLAKE2b-256 2eb463e07ec9ee4c31d33f5fb831dea41990b4f5bf7ae198f97a391c610e8073

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.11.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84ceda25e87eec3eca09c0a1af7ec460b3a572c707f8cd4af0e9387beab23f12
MD5 2562d322984c6d73a9e9ba582e7c3e16
BLAKE2b-256 2c8956b44c7aa8e4caa77db5553b94cca95f8a27aec008c26d0fbd8284496082

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.11.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a4721f2a107887c0c37d89820bdd0ad290411a9d6461ba9dd536d16fca6f18cb
MD5 612a81a78d1b7f40ed0391aee506b3f8
BLAKE2b-256 25955c7adb1e61963965f926b7302cb9d78ee0ce1ceae9f00fb24829d3258dc9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.11.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4e54150c4300a7d738abd441c5aad182fa3bdefa3bea3fca918b0266b1e75d13
MD5 b949a1f7544524fc3d57f967feec9ca7
BLAKE2b-256 9a24d766ebacff55b81c5a205e790066ba4ca1d01a8825fc828f751f41c39f0e

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for asyncdb-2.11.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4425eba5a5fbd5a3869bc76a5b17de73c544830c4bed292c2e45475cfcfb9e79
MD5 748cc3cf5245d317d9289c28a8062be9
BLAKE2b-256 053c3ca767a54161185920f0166ce0b9f590bbd7b37341ee2338f2458fc98faf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.11.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e4514f784c7c9da98875421c34dd5c8e5c475c79ce9e1d79766fbc2b231f1108
MD5 e609f33c8dc4202a50d20810859b8f9b
BLAKE2b-256 bac097237549702c57daba1d8ed2c756354f97dadbd618795ff48387cc7948b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page