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

Uploaded PyPy Windows x86-64

asyncdb-2.9.3-pp39-pypy39_pp73-win_amd64.whl (242.7 kB view details)

Uploaded PyPy Windows x86-64

asyncdb-2.9.3-cp313-cp313-win_amd64.whl (247.9 kB view details)

Uploaded CPython 3.13 Windows x86-64

asyncdb-2.9.3-cp312-cp312-win_amd64.whl (248.7 kB view details)

Uploaded CPython 3.12 Windows x86-64

asyncdb-2.9.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (927.0 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.3-cp311-cp311-win_amd64.whl (251.1 kB view details)

Uploaded CPython 3.11 Windows x86-64

asyncdb-2.9.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (855.4 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.3-cp310-cp310-win_amd64.whl (250.6 kB view details)

Uploaded CPython 3.10 Windows x86-64

asyncdb-2.9.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (795.6 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

asyncdb-2.9.3-cp39-cp39-win_amd64.whl (251.4 kB view details)

Uploaded CPython 3.9 Windows x86-64

asyncdb-2.9.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (798.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.3-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d25bc863a4db1ecc7fdda69c055fbd24c562116b412bbb98d3b43dc1fec15f64
MD5 3d26229e940e979384013b21194b912b
BLAKE2b-256 13323ff6ea0cc4406d6072bd9c3aeaa8bd3fb21d845c1ec632487c532ddf9da0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.3-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d27591b576a7627ca48be86042a25b1ba10dd6ddba38e7f4da9983328ba2ee99
MD5 2ce4cb7102805bed0308a29a112c3a9b
BLAKE2b-256 9f23f992016f35b996b68bab59898fd5e699ae529872a06b5099255b608c5da9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 247.9 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b139ee005078cc11b1b98fb60c0c5e89bd39c1df739748e09365d1690797954e
MD5 571c514ab157212868d89fb2b75e4626
BLAKE2b-256 a4e2be30ea90ae2fd02f0f55b97f952a1728432e92756c478cd8f5bcbb1873ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 248.7 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 17c129ea7d46b6693bb02105103f79596f653e048aa64eaeff853f8cefe50536
MD5 a9494a60a5e7bd77d84d71e1fb02af4a
BLAKE2b-256 44d879e88f9a12ad8f3aa42a10d956077fccdeaf2aac5134f5861ccef19af883

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 89357bd771821ab00df481b7b6e5e0c0886926b1e1d22252ebbc5556b5fe8f23
MD5 98d621dd53ea06878c3874aeca056329
BLAKE2b-256 704307dd0ab8b39897c79f51ae76732aa43d77a7816c4e65103830e909faa8c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 251.1 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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ee79e24914217d70dbc5a8ce81d6a90cb1b798e6add529d2be290561d172f2a0
MD5 46cab65a1ab5ede01aaee71e48db63b9
BLAKE2b-256 362d5b28d8ee59a0827a7219b80df35facf07bcd9595a42e911fcb4b0ab47fad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fa26ce557190b9a8575c0413e40a75b36c6068a4effb42b8a4ba781ec46885e4
MD5 0d9f73b112024734901c9fbc9768d338
BLAKE2b-256 654a7448ac1f13cef4aca75180553a33baac63a37a905e7a67d94ece9bac1821

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 250.6 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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 82bb54f6ba2b7b1361e602326c75e1ec61e1a04b3b2cb6a9154aa108b61de86a
MD5 fee0fed39b059c29e5adb8970f07e2bb
BLAKE2b-256 925140804ca0d8d1ceac1b98481c40161e537bb1dc48cdd7e44b07efc4189df4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8b406772e903bc5b15a5df20eb1b70eb754c2d88633c026ece911949a2f51ab7
MD5 ba1c09a533f7a3d836d8d719b23c29af
BLAKE2b-256 9269ebc202b42c6daa33f94736736111ae79bf5c25ab6354f734a9031f63d5a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 251.4 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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e21ba5b0cfaacdac1012b26f82a4fdb1a35ca2cbf61ecc31b972c928b488c08b
MD5 eb70387379ce470fbf2dd503b8300dda
BLAKE2b-256 4979430b424036e53dd7472673c5f7a200573de3ec68b16d250000d4442ed81e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 324b40f6d0afbdc9f290778975769a8dc47b882915c9f73d92beadf7501da5eb
MD5 f774d69aaded1e5c0ce266ff06ceccf9
BLAKE2b-256 12439e283fb704ad74e58d5054384c8d73e54fd40f1866ce5ae6987a36d25f9e

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