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

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

Uploaded PyPy Windows x86-64

asyncdb-2.8.6-pp39-pypy39_pp73-win_amd64.whl (227.2 kB view details)

Uploaded PyPy Windows x86-64

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

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.8.6-cp312-cp312-win_amd64.whl (233.2 kB view details)

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.8.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (911.5 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

asyncdb-2.8.6-cp311-cp311-win_amd64.whl (235.6 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.8.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (839.9 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

asyncdb-2.8.6-cp310-cp310-win_amd64.whl (235.1 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.8.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (780.1 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

asyncdb-2.8.6-cp39-cp39-win_amd64.whl (235.9 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.8.6-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.6-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for asyncdb-2.8.6-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 42eb3eb5c832f24685a49a3fa43ff95a61ea7aaddb85d4184f6af78a5ede3233
MD5 46f697f47b16cb2e9040222da43d841f
BLAKE2b-256 97794a327fcf0c6165f9a68a87bffbce927a18f3b41b7459dfdaf8f1f9715f5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.6-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 201368f6207b91d2d5fbfaa003dda4ad759a9baf57c739b149c4457e158b9efe
MD5 93aa4b0d79e0c4f96386a0e49faefa35
BLAKE2b-256 3f35178423c1033aebbe9ceff16cf588811096a4e55552e69f9e7e1734b5dca1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.6-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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 4cb7fcfde1012ec90f07d14d8b3c9a9f4681d8cd853529c52086e05c16ce8671
MD5 173708e5467d10df8453215e21359707
BLAKE2b-256 3a15939c57f43866930492ae9d5afeb020221af894d4692611a51539ceab7afb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 233.2 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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 34a5aa4cdce72f40effc6f13ddc1b568dabf70da32b3a2e4cf114928e75fd283
MD5 3c5176349b00bb8972f8f1bd4e2cf557
BLAKE2b-256 f90d6b6a5cdd678764403f7defdaecf740a735a52fa85d57315fac51704e6de9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c141ac11da8229ace0df928503dc8dbe87476dc6a3cfa559036b2cdc3a3a5ecd
MD5 1955bb44cc9f0e7ff5cee49db534b6f3
BLAKE2b-256 f6f12bdd954328969a05add03223dd5a1a8876ca555b2d0cc1fb258298f385e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.6-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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cfab9dcec1688d5a20075b625ba444fe63230e06365fb60ec551f93fd18d7ae6
MD5 1fd48d6a264ff5310ab9b7b87d1ee95c
BLAKE2b-256 d02f55acf044fc80f8737697e0af87f878e1eb9fbc88035bcc69381dcd401442

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 827c68237e8d06142b8e471d8165947a3d872ac393085d369c4413fd7c644238
MD5 7850791a97e4d218d23fed52671d7795
BLAKE2b-256 204c5e2d3ef6a9fd13bffa93930dd91c70b75c62abc68e38caa32052e8d7fe88

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 235.1 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.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4867739b7eb17dbddd6dd46b59520d0aeb3cede351dd2a4528804b2e0fbeabe8
MD5 b5a86777fa54e6657910cc43146e3cdc
BLAKE2b-256 72fadc68d992051829168f6900d98ea125a8f7a6df331823e439ed784e2faaf9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0515c4ca9660729ae29c9821ab7e62c56570c578fe39e4f0fbc25d6d503c48b7
MD5 683f07cb900de8685dbc13bb3831b34d
BLAKE2b-256 d6fcc6c247f875f001508e4c58a3c17d9cc2ec21dde9ea5d520015cd2cad8d7f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.8.6-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 235.9 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.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 0d7b47ab54b8f45b692ca662aee7cbf624e2c8a0bc3313888459fdf2292af620
MD5 9f2cefd988848016658c10217510198c
BLAKE2b-256 74ec8056a20ca2672e902312d7c11e4c77792b70bbffaef11da24818c4f0badc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.8.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5d6cc9d4235ef8a0a08849b8252f338bba9e16816b04a3c95849fa9d91624d6a
MD5 735e9c79b7e27c7ff66393df18c36db2
BLAKE2b-256 9574a878fe0ad1fc4c1d24c263b748b0d1a78ade9f3fab4b0596cb3b48af4817

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