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

Uploaded PyPy Windows x86-64

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

Uploaded PyPy Windows x86-64

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

Uploaded CPython 3.13 Windows x86-64

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

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.9.9-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.9-cp311-cp311-win_amd64.whl (251.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.9.9-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.9-cp310-cp310-win_amd64.whl (250.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.9.9-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.9-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for asyncdb-2.9.9-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 91abe60ba3b12e8497bb367bbbd7fc1eedeb977eb11706a72e53fcb0c564d323
MD5 fd23493e3e9baab50763360b8a6509cf
BLAKE2b-256 d5ee43590fc49648957fcdaf6fc7161564a1e8cb59530a4dbe0e85301e899f9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.9-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 b13544d7f447ae8e4febf048ad61a2e3eaf8c89b0c274940ee8b44bdfd9864fa
MD5 e4007d75398deb5a8d0595938f2527a9
BLAKE2b-256 db4702bf4e41a640624dcacd734693c0503567d2eba63c3d9009bf7f5bb0149a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.9-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.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8c3a73c8a50f4463bb8ee47f8e6070498f99d1abb248243eca25f68903255e03
MD5 e0d8e719b8bdeeedb17b595916e24abe
BLAKE2b-256 df300736f3338f4a07bff9b812e1fd08dea83d49532a9b6c2fb79e443c2d394c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.9-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.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 87f751c5e4a595a33f20a922bae5dbae4186cdb49d2de0556dd87b009dd8de20
MD5 db40fe165ed120eb2d91de658d89ade6
BLAKE2b-256 b7d46e147978313f52d81946b521b4de595537084443adaa0bedb3334faafad3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.9-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 499a09b8130878b7930b5b96f034bef90b9b92b2bba544f281d6bc9ba18c7b10
MD5 606ca08fe31ed1541ed1830bba0722fc
BLAKE2b-256 0422587312c6a1ad2896c48b32d7454aefc87c8895a6298bfda819b06ed3faab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.9-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.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8217efe221f482515872882068c9ad95e2b17a58f7806d938e23d595bd206a36
MD5 80beb7ffa01be82da0ce972a586f5f12
BLAKE2b-256 df5c74e1acf1610295680b1698ae559326f803b66f0347dbdab6dfd00f587000

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 dccde6fa7427a5481a85df6a5950fd731ac8c71cd329b9567774394fbf605caf
MD5 d75657b271b8258dfe51580c2d4f8c5c
BLAKE2b-256 608674b6336f397310caa80a5d648f09a77aca57ecce1dce1f35a665d89378b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.9-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 250.9 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.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a9b76f5c7003b4894fab58cd3714eeaaa0f5d026d59bbdd6d95cd01563caf89c
MD5 781b3a1a8d2b5a17403230efbab79bd1
BLAKE2b-256 e4e868b04da15f60e9baa1caf7be246b03e2f412378aa25e904f2e852db2f2e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed5ae69d048c123fdba3c42ec4c708939f83d6618de27182418dd4b8af7c2f52
MD5 c0ffdd233d23887fcef6da7dbcdaed5e
BLAKE2b-256 d0d6e878e5cdef30aca9f6ba559f76a3e6d25028c6619d3e65116fdc3c19d1e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.9-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.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 3e1f566bff04d94ec033f4bc1fec2d7d496440a80ff28a054e4c03d517c039c9
MD5 3f3248977c4f212bc464a89013e0ccf9
BLAKE2b-256 c0b09077bd653662a1805ae4a281128c974dde22ada57f93312379e6277902ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 03913af61be464b7c79d3f0d94cdf68ae93a15ff7147bbd3cd76fbada980234d
MD5 ab2163341fc67a998d7fb42addb2cf7a
BLAKE2b-256 fe65d15abfaa188fe2edbc23b884fc601c7f4685017482d4f904449d3bf3de49

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