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
- Python >= 3.8
- asyncio (https://pypi.python.org/pypi/asyncio/)
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 (optional, requires aiomcache:
pip install asyncdb[memcache]) - 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)
- Redpanda (Kafka-compatible, requires aiokafka)
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)
- memcache: aiomcache (Memcache, async, no system libraries required)
- odbc: aiodbc (ODBC)
- oracle: oracle (oracledb)
- redpanda: Redpanda/Kafka (aiokafka)
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.
Release files for asyncdb 2.16.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 5.4 MB
Release files / asyncdb-2.16.0-cp313-cp313-win_amd64.whl
| Download URL | asyncdb-2.16.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 252.3 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b4f1e8455183a98eadc6cb495599dc7d74e6f6fc32fa76eb50983565584240f1
|
|
BLAKE2b-256 checksum How to use checksums |
f9187b478ebed02d66aebacdee2ba93f1f3fa0ca6a7d3750761806741becce15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | asyncdb-2.16.0-cp313-cp313-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 570.7 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
26b77d7b7d9cdd2e51049d632ed02d7c339509e7157f49efa7e3dd403f27c45f
|
|
BLAKE2b-256 checksum How to use checksums |
f264ad7de6501559c3691299ed6610f463dec8567890131e82a9f334f069d90e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | asyncdb-2.16.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 264.6 kB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f9825a6ef7df48315ae59c590807b6ba71e2d4526a46108970b2acda9c7b991a
|
|
BLAKE2b-256 checksum How to use checksums |
bd0e0e2d896f051fa4654a451a57acb9efe8dff158d05ec44d4d155b47116387
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | asyncdb-2.16.0-cp313-cp313-macosx_10_13_x86_64.whl |
|---|---|
| Size | 265.6 kB |
| Tags | CPython 3.13 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
bbe4088e60f3f187399bc5f510266177e16722b75ce40082224cd22bc65dd65e
|
|
BLAKE2b-256 checksum How to use checksums |
a4e4cb89f53039de168e7fd872a7522aa2c0d730ecae90ee3c14dee54b34501b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp312-cp312-win_amd64.whl
| Download URL | asyncdb-2.16.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 252.5 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
e9a94874198921ca33c8d4f0adb85d4bc85fcfad799ef83330512be0b9fd5148
|
|
BLAKE2b-256 checksum How to use checksums |
f350bf8d39df347e302fa864b12c7a6989bbe9e01e8d59f350efc1c5f1f45fe2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | asyncdb-2.16.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 573.8 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
2e97969ec8347622da1bd5cac7f30d6d8366e739aa03d6b2ca8458d2d1f2bba7
|
|
BLAKE2b-256 checksum How to use checksums |
746536359a195629d8451e8ff46343b5662be1eae0cb6b13cf73a2dd29810b77
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | asyncdb-2.16.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 265.9 kB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
83401ff200639987bf135122d27a7927570cde6c72784cbafe8cee1569b5342d
|
|
BLAKE2b-256 checksum How to use checksums |
9d64bba445d1ac997d77789dd646ff1868a0145e59388b7bc70c716b205ae6e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | asyncdb-2.16.0-cp312-cp312-macosx_10_13_x86_64.whl |
|---|---|
| Size | 266.6 kB |
| Tags | CPython 3.12 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
c467a8925ca1e70e8d6a582e3f8a9de7861152b9a3fbcce8d6ded73294e39e40
|
|
BLAKE2b-256 checksum How to use checksums |
ba7a8de2aeb54c3eb7d05fba231e569844a9fde3cafc64eb7b88356fd94288fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp311-cp311-win_amd64.whl
| Download URL | asyncdb-2.16.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 252.9 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b2f3b6f362739eb2c879ff726729d2ef3c232ac8848969f4dfd7100175abcecf
|
|
BLAKE2b-256 checksum How to use checksums |
4ef2a1851c1bf3a93000315821fd69087c2f35da1dcf54d6f94ff10e0d28db4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | asyncdb-2.16.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 577.0 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
3c6f1115ca3d95a787eccf896dc9e2e42ffadca23f9e5fbdab3ad3eb3f3b0dd8
|
|
BLAKE2b-256 checksum How to use checksums |
c9983566bb4339e2a048a50d87bda50f89fd55ed03e3adf9cc1143f32d4bba7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | asyncdb-2.16.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 264.3 kB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
3d72e07b78ab381bd2e6781b7b8d1eafad68a41134454b9c89497017b3705eeb
|
|
BLAKE2b-256 checksum How to use checksums |
4ddf6cada657dbeed515cf9f20a45efc867b4861ce619cb829fa00b33fdaad2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | asyncdb-2.16.0-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 265.3 kB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
7a99a85e9d6370229a20bc5e8b71ec78b2079a5144bb8325d7522209ec3c41f2
|
|
BLAKE2b-256 checksum How to use checksums |
38b857fb8925a12cc3179a685501059adc3c6f2ae5248a676afd258e3bc5a414
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp310-cp310-win_amd64.whl
| Download URL | asyncdb-2.16.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 252.4 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
16ea38a1b875eb6a71dc0ea527046fda8a7064f9c81fc84e7f71d81d1a16d8ee
|
|
BLAKE2b-256 checksum How to use checksums |
56f6750ca66fa7c19cc3a4032713fed13036d7e2fdbdd4e2e81de65c020f017f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | asyncdb-2.16.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 544.7 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 Linux glibc 2.5+ x86-64 |
|
SHA-256 checksum How to use checksums |
8f2cedfe34b5536f0d0eb4082b8e5a7b193c86e69a1670165f3517e6f87b20f1
|
|
BLAKE2b-256 checksum How to use checksums |
365e045e6bab69214f597dabc2ee818637351299d6f3c1df794309b38bba944e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | asyncdb-2.16.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 264.3 kB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
277a1dcc2285a54e432eaac66071b0ac55724abe3b3328494e0155e879ceab35
|
|
BLAKE2b-256 checksum How to use checksums |
fca0e62d0ae0bcebebf79e98571e04a03669d3dcd72322b5454ac35bd911a19d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / asyncdb-2.16.0-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | asyncdb-2.16.0-cp310-cp310-macosx_10_9_x86_64.whl |
|---|---|
| Size | 265.2 kB |
| Tags | CPython 3.10 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
2b1695fbc283dcafcbc21f16291c8352c7478d8f32837f1a66647b184e7c37d9
|
|
BLAKE2b-256 checksum How to use checksums |
e2ea45220ab7aed21cb7c071c5b1d0573fd908b3bef74bab3d9d3bdecf09ecf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|