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

This version

2.9.8

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

Uploaded PyPy Windows x86-64

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

Uploaded PyPy Windows x86-64

asyncdb-2.9.8-cp313-cp313-win_amd64.whl (248.1 kB view details)

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.9.8-cp312-cp312-win_amd64.whl (249.0 kB view details)

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.9.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (927.2 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.8-cp311-cp311-win_amd64.whl (251.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.9.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (855.6 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.8-cp310-cp310-win_amd64.whl (250.8 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.9.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (795.8 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.8-cp39-cp39-win_amd64.whl (251.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.9.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (798.7 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

File details

Details for the file asyncdb-2.9.8-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for asyncdb-2.9.8-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 15937db73c52c2a5d8fedd2a2d79cdbb4344763e6ec5609b95f8691f3cbaa6d4
MD5 cfe8627e0338c0bcb18e13963a379d2c
BLAKE2b-256 1730fef1e155fa1c22857213bc56451338d87080c6002989fbd4e5aa35847302

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.8-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 e536f4018973e811db25e14b78dfa02c70853c644eca671ec270939132fdb2ee
MD5 aa84571935e043e3a7b5107737c5d569
BLAKE2b-256 83d3fa1a53b336e6f0f689fc2c934a59e41fd4eb808dd4f71f7b37ee5601d317

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.8-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 248.1 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.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d1bf763d14b3d9b7f453a66d79e844a7e92278b459fce8d3562efa2186dfb05d
MD5 f7c0e362f190dee732f218ce7da4ea6b
BLAKE2b-256 a462c7d28a9875e49a0d2314502902444f17c30ee0aadff9529bedbc374172e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 249.0 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.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1cdd9f2732e7fc63e2293b00bfc04ea9973c7faf4977263ee065ae7f517e48a2
MD5 640e9af49ba0e21c2d10877ba8724cee
BLAKE2b-256 d858b5e94a96719714f359a8bd23e2c518d8a9d9e647e6c4bce223f2211bc736

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.8-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c767043402186dac4bd5f08d798f34295cb9272624f91409cfced93808cf53b
MD5 37e51597ae3cbf606c3ee5b0cba89b51
BLAKE2b-256 586fe780c0cfa8345c877e652e0543da5828fa5c9c47f85a99251120025bfceb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.8-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 251.3 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.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5b898a026dd81a2ce4fb3c8ab14ef14f64abe176b51ec72d75bb2fb31b010342
MD5 a938f1d99a0543d3b7b4322fe65dcef5
BLAKE2b-256 9233f0fa5c382dc5004e4e75236af60adc69833d2ba6f533facb638c0f48f3db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f6d8b3a7e9748e9554e5c77a15fdca177e83fe944c47828090f73dc9040bbd0e
MD5 d0c7dc577b74e52e8cfcab1fdcea861a
BLAKE2b-256 9350a8546f2dc2b1d6aa136794518af66598d7624bdba5974c5059e39ff31af2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.8-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.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 69c6c540011642eef0e6d559d757fd4c9954d3c5d915bf87b85517bafff0a056
MD5 e528008027f28df5facb73798ddd40b0
BLAKE2b-256 e85f324c3f28dab4659b2155b53ae27d8080d5c6c6edcf57c69e11b576f8674b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3fc85016dc01e5a2bada493cbf168cda23925c9b73079408507126c664f338ae
MD5 fa03496a63d8172795f810e812d4145b
BLAKE2b-256 aa5eb9075a82621bf769cce69a335907a7dcee6842a999d6dac60e15784d982a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.8-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.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 cc57b8f894e9ae7a64891cd847816279b829566a6065e278c5e1abb37bd238e8
MD5 6cb412a0ac9345955eeb7df6a48cdfd5
BLAKE2b-256 7cbdb579017a37e1f871e834363bccc18aa9644a8d2986c9ee47096c58aa7c56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9b9dbe2711fb28660080e76a1a5c5e74689d013cd921d6f9a56880542a5654da
MD5 9fa490772b3b9c27dd723bc8fbec5269
BLAKE2b-256 6041bd7289b9d089eef1dde3a9aa838182f188009df3715779b5b8f90573085d

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