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

Uploaded PyPy Windows x86-64

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

Uploaded PyPy Windows x86-64

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

Uploaded CPython 3.13 Windows x86-64

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

Uploaded CPython 3.12 Windows x86-64

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.9 Windows x86-64

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

File metadata

File hashes

Hashes for asyncdb-2.9.6-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 62f1c62c8f26ba9b0776b38a53e81252f8f5c2052df62a56ca22e30080beca04
MD5 f20f625c0d98d19b56f10c70acc75259
BLAKE2b-256 1ccc4177474b12d7b9e35774c66075471dfbdae92933d323eded06537f7e7ab9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.6-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 6c9e86d19883857c1fdb9857db897ba6cd99ac1aabf6f04139b41ad9eba02161
MD5 daf3120d8741dc2b554b8499b90eb69c
BLAKE2b-256 ecf8c9433d1b1b401ed9ad08f29dc41cf748a7a8686972abe710554220ccc206

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.6-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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 382da37e3b507f6b2c336ebdf1265656eda5fbe4cd8572fbdb0cd4c8f1a60abc
MD5 622ff7d6f8655140e99cbb09e1644347
BLAKE2b-256 4e5b7bf4cbd22af65f0ee5652d59200c6795d0352047fab3285baa46de113467

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.6-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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 94661cfe6551b3e8477b719955f4abff6b5ed1e5e7cfafd5c162c9b6d5173050
MD5 9e2615a770f5f86729348e44d6b15450
BLAKE2b-256 49bf9213b7c174df2e3cdeaeb8de5baf4cae002e389895b3cd9bfbed6b473ef4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.6-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5925c96e04184f83f634bdee5b5247a8bab0c66950900b561c58a29de014fdd9
MD5 0e98da4f5a19badd73dd4e1e664b7b4a
BLAKE2b-256 c81c6839dee360bb7376c2aed09a6a052d5d4eb3b5ec1c9b31d6a90a8328909d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.6-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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 dd477e3674f21c60c579bfbe7e945271fe0ead2743cbe58db0810ca500902b18
MD5 8f35a56af8fbb799caaa2c507f9bb7a8
BLAKE2b-256 84a2922a35f5c926d0f75b5d7e57e898182b10bd875a50eb4c0fed90a9e142fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.6-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3a53d056477ce6d9f5c9be37829b1f9a2019f9dc27b233773a5cc41f24a7096a
MD5 e6a37a8ee45c41434c4e81e0fc49d822
BLAKE2b-256 be6b99ffedee91cc8fbbea75e20f858724805c2bc4bea63de6321791ed10b6b8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.6-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.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7b988994c796d80ca8befc957d7b1189dbf416907b5717c42768e382aa7dcbe6
MD5 4e483e3518f01ce61efbf9b115ca84b8
BLAKE2b-256 179c525770e35a7d4c9a0a95eec76c3b860f45d0ce57e6fbfd6113fb537cace8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 529d85652b4a6a088d0b98255b7c1b0137085ce56ced25764fddf70d2b1394b2
MD5 76d27a305781cd66d60ea56871750d1f
BLAKE2b-256 757bd8b1a5bdc9442662fa1a3b136c832610a0ce9b09a8f46c9c05fd1d0bba57

See more details on using hashes here.

File details

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

File metadata

  • Download URL: asyncdb-2.9.6-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.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5dc80e859c9cf5b60ad913826e078eaaa43182390a96a80a323433d62031ca3d
MD5 3b69dd4f86bbf1bd57c0ac517c779d83
BLAKE2b-256 d19a2881a4b0427e8ab9d5c56dd333b2dedea428fe377f405547a647c709d090

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for asyncdb-2.9.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 31873c57fc4b07327aed9d39e4ccecc79b95edf5046a936b5e290c19ab3846a9
MD5 4b0ec3bd8f9dc9a0fb1553cdd630052b
BLAKE2b-256 666b97f3d0c3456bfedf25d4e9c474bab922e52991971dd4e594f6dfaca9d448

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