# 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
<div class="termy">
```console
$ pip install asyncdb
---> 100%
Successfully installed asyncdb
```
Can also install only drivers required like:
```console
$ pip install asyncdb[pg] # this install only asyncpg
```
Or install all supported drivers as:
```console
$ 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 (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 ###
```python
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:
```python
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.
Raw data
{
"_id": null,
"home_page": "https://github.com/phenobarbital/asyncdb",
"name": "asyncdb",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9.13",
"maintainer_email": null,
"keywords": "asyncio, asyncpg, aioredis, aiomcache, cassandra, scylladb",
"author": "Jesus Lara",
"author_email": "jesuslarag@gmail.com",
"download_url": null,
"platform": "POSIX",
"description": "# AsyncDB #\n\nAsyncDB 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,\non other blocking connectors (like MS SQL Server) we are using ThreadPoolExecutors to run in a non-blocking manner.\n\n### Why AsyncDB? ###\n\nThe finality of AsyncDB is to provide us with a subset of drivers (connectors) for accessing different databases and data sources for data interaction.\nThe main goal of AsyncDB is to use asyncio-based technologies.\n\n### Getting Started ###\n\n## Requirements\n\nPython 3.9+\n\n## Installation\n\n<div class=\"termy\">\n\n```console\n$ pip install asyncdb\n---> 100%\nSuccessfully installed asyncdb\n```\n\nCan also install only drivers required like:\n```console\n$ pip install asyncdb[pg] # this install only asyncpg\n```\nOr install all supported drivers as:\n\n```console\n$ pip install asyncdb[all]\n```\n\n### Requirements ###\n\n* Python >= 3.8\n* asyncio (https://pypi.python.org/pypi/asyncio/)\n\nCurrently AsyncDB supports the following databases:\n\n* PostgreSQL (supporting two different connectors: asyncpg or aiopg)\n* SQLite (requires aiosqlite)\n* mySQL/MariaDB (requires aiomysql and mysqlclient)\n* ODBC (using aioodbc)\n* JDBC(using JayDeBeApi and JPype)\n* RethinkDB (requires rethinkdb)\n* Redis (requires aioredis)\n* Memcache (requires aiomcache)\n* MS SQL Server (non-asyncio using freeTDS and pymssql)\n* Apache Cassandra (requires official cassandra driver)\n* InfluxDB (using influxdb)\n* CouchBase (using aiocouch)\n* MongoDB (using motor and pymongo)\n* SQLAlchemy (requires sqlalchemy async (+3.14))\n* Oracle (requires oracledb)\n\n### Quick Tutorial ###\n\n```python\nfrom asyncdb import AsyncDB\n\ndb = AsyncDB('pg', dsn='postgres://user:password@localhost:5432/database')\n\n# Or you can also passing a dictionary with parameters like:\nparams = {\n \"user\": \"user\",\n \"password\": \"password\",\n \"host\": \"localhost\",\n \"port\": \"5432\",\n \"database\": \"database\",\n \"DEBUG\": True,\n}\ndb = AsyncDB('pg', params=params)\n\nasync with await db.connection() as conn:\n result, error = await conn.query('SELECT * FROM test')\n```\nAnd 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.\n\nEvery Driver has a simple name to call it:\n* pg: AsyncPG (PostgreSQL)\n* postgres: aiopg (PostgreSQL)\n* mysql: aiomysql (mySQL)\n* influx: influxdb (InfluxDB)\n* redis: redis-py (Redis)\n* mcache: aiomcache (Memcache)\n* odbc: aiodbc (ODBC)\n* oracle: oracle (oracledb)\n\n### Output Support ###\n\nWith Output Support results can be returned into a wide-range of variants:\n\n```python\nfrom datamodel import BaseModel\n\nclass Point(BaseModel):\n col1: list\n col2: list\n col3: list\n\ndb = AsyncDB('pg', dsn='postgres://user:password@localhost:5432/database')\nasync with await d.connection() as conn:\n # changing output format to Pandas:\n conn.output_format('pandas') # change output format to pandas\n result, error = await conn.query('SELECT * FROM test')\n conn.output_format('csv') # change output format to CSV\n result, _ = await conn.query('SELECT TEST')\n conn.output_format('dataclass', model=Point) # change output format to Dataclass Model\n result, _ = await conn.query('SELECT * FROM test')\n```\n\nCurrently AsyncDB supports the following Output Formats:\n\n* CSV (comma-separated or parametrized)\n* JSON (using orjson)\n* iterable (returns a generator)\n* Recordset (Internal meta-Object for list of Records)\n* Pandas (a pandas Dataframe)\n* Datatable (Dt Dataframe)\n* Dataclass (exporting data to a dataclass with -optionally- passing Dataclass instance)\n* PySpark Dataframe\n\nAnd others to come:\n* Apache Arrow (using pyarrow)\n* Polars (Using Python polars)\n* Dask Dataframe\n\n### Contribution guidelines ###\n\nPlease have a look at the Contribution Guide\n\n* Writing tests\n* Code review\n\n### Who do I talk to? ###\n\n* Repo owner or admin\n* Other community or team contact\n\n### License ###\n\nAsyncDB 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.\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Library for Asynchronous data source connections Collection of asyncio drivers.",
"version": "2.10.2",
"project_urls": {
"Funding": "https://paypal.me/phenobarbital",
"Homepage": "https://github.com/phenobarbital/asyncdb",
"Say Thanks!": "https://saythanks.io/to/phenobarbital",
"Source": "https://github.com/phenobarbital/asyncdb"
},
"split_keywords": [
"asyncio",
" asyncpg",
" aioredis",
" aiomcache",
" cassandra",
" scylladb"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "42ed856e95b0a2d97b736be6e39edc8ede91addd00b9bf6fa6fb8aab0f4c8e25",
"md5": "c7422b6c9d9e91fd74d4d15d650ecdd7",
"sha256": "ee26a4f4f8638c59e44e6b9f54538c3020f7261f5533d39d8fbf5f9048bff88f"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "c7422b6c9d9e91fd74d4d15d650ecdd7",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.9.13",
"size": 798085,
"upload_time": "2025-01-10T22:53:54",
"upload_time_iso_8601": "2025-01-10T22:53:54.134619Z",
"url": "https://files.pythonhosted.org/packages/42/ed/856e95b0a2d97b736be6e39edc8ede91addd00b9bf6fa6fb8aab0f4c8e25/asyncdb-2.10.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "81581d3fdf58293f4b85d4f57ccfae9c770e2788ce6e01ff2d7c5ad2a89ef325",
"md5": "a1c5e04bd5d4c687fb15a737fe576206",
"sha256": "f248034d29e7d0bc637304736819c7091b6b891bc1d9448636134515ebb7bf69"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-cp310-cp310-win_amd64.whl",
"has_sig": false,
"md5_digest": "a1c5e04bd5d4c687fb15a737fe576206",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.9.13",
"size": 253095,
"upload_time": "2025-01-10T22:54:07",
"upload_time_iso_8601": "2025-01-10T22:54:07.079481Z",
"url": "https://files.pythonhosted.org/packages/81/58/1d3fdf58293f4b85d4f57ccfae9c770e2788ce6e01ff2d7c5ad2a89ef325/asyncdb-2.10.2-cp310-cp310-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "be955c91cce80d7742523549c647e8eb8511dae9fc8b774bbcd61d972f6c930f",
"md5": "39731b0570b496ca85c8c60591a79daf",
"sha256": "c452e4d84d9bc1d02f5f74750809d7b476de4dd9ecff404b5335d99d723b15e0"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "39731b0570b496ca85c8c60591a79daf",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.9.13",
"size": 857861,
"upload_time": "2025-01-10T22:53:57",
"upload_time_iso_8601": "2025-01-10T22:53:57.503056Z",
"url": "https://files.pythonhosted.org/packages/be/95/5c91cce80d7742523549c647e8eb8511dae9fc8b774bbcd61d972f6c930f/asyncdb-2.10.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6ec437203b52a04f34476125b7c2e357137d4369ea299e3870f3f516fd82704b",
"md5": "2fe72732c617c631d166f53ad0ee03d6",
"sha256": "e756cbe0b7784c2287c1487c72936e8815245d35d9333aa2307b64cbb66cee23"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-cp311-cp311-win_amd64.whl",
"has_sig": false,
"md5_digest": "2fe72732c617c631d166f53ad0ee03d6",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.9.13",
"size": 253586,
"upload_time": "2025-01-10T22:54:09",
"upload_time_iso_8601": "2025-01-10T22:54:09.510436Z",
"url": "https://files.pythonhosted.org/packages/6e/c4/37203b52a04f34476125b7c2e357137d4369ea299e3870f3f516fd82704b/asyncdb-2.10.2-cp311-cp311-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aa1a197bd17e8fe57b9eda8d02202dd72ca4683e2bdd0abd190641867cb1d9ab",
"md5": "edcbf8afb0ddee49fe4ac9b3993b3e03",
"sha256": "bc1b4fdca898a3d5c32f2a3d5c25987a4f97bb120cac57e907cdbb2ec1c72a71"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "edcbf8afb0ddee49fe4ac9b3993b3e03",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.9.13",
"size": 929481,
"upload_time": "2025-01-10T22:54:00",
"upload_time_iso_8601": "2025-01-10T22:54:00.209297Z",
"url": "https://files.pythonhosted.org/packages/aa/1a/197bd17e8fe57b9eda8d02202dd72ca4683e2bdd0abd190641867cb1d9ab/asyncdb-2.10.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cd30ec9c569cfac3246eedc2369a3ea575edf358910062a6dfc53df8fdade045",
"md5": "7e305720b0e92a36fb1a78090d1510a9",
"sha256": "5ba8e1a04176e415ca5ab5d20d568f28a40c8dac0d8aed480c086acfcdd5e31b"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-cp312-cp312-win_amd64.whl",
"has_sig": false,
"md5_digest": "7e305720b0e92a36fb1a78090d1510a9",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.9.13",
"size": 251313,
"upload_time": "2025-01-10T22:54:12",
"upload_time_iso_8601": "2025-01-10T22:54:12.101602Z",
"url": "https://files.pythonhosted.org/packages/cd/30/ec9c569cfac3246eedc2369a3ea575edf358910062a6dfc53df8fdade045/asyncdb-2.10.2-cp312-cp312-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "430d6e242e02455a1d5fdba97d4dea76648415436535d91326996dbdfdc7a1ac",
"md5": "5e19c42adc85074f14d0f64c186d973b",
"sha256": "77a3fb97e1da7df2fda01a6c115f99a1ac49c751a2fcfb7fbb7debc4399e133a"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-cp313-cp313-win_amd64.whl",
"has_sig": false,
"md5_digest": "5e19c42adc85074f14d0f64c186d973b",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.9.13",
"size": 250024,
"upload_time": "2025-01-10T22:54:14",
"upload_time_iso_8601": "2025-01-10T22:54:14.745126Z",
"url": "https://files.pythonhosted.org/packages/43/0d/6e242e02455a1d5fdba97d4dea76648415436535d91326996dbdfdc7a1ac/asyncdb-2.10.2-cp313-cp313-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aa9b5ec27a8c8f035a94237e81e60928e464acf2d2b1202512ed546e73acc4fc",
"md5": "81b8e5856c278c344a0f927f17cb5f4c",
"sha256": "c97658cc64dd022a40a5d60c51b496557e38b496eb30f85186139d627d0026b1"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "81b8e5856c278c344a0f927f17cb5f4c",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9.13",
"size": 800939,
"upload_time": "2025-01-10T22:54:03",
"upload_time_iso_8601": "2025-01-10T22:54:03.393449Z",
"url": "https://files.pythonhosted.org/packages/aa/9b/5ec27a8c8f035a94237e81e60928e464acf2d2b1202512ed546e73acc4fc/asyncdb-2.10.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3d18302176545de65531f5a83a0b16af317a40f93d790cf405893f704bca8fdc",
"md5": "cb514478f7bb3c707797728cdd07e5e1",
"sha256": "547f721074455fd08acef1ae33cfee2ffb528c5fd4b5b07e682b5e7dd76e9973"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-cp39-cp39-win_amd64.whl",
"has_sig": false,
"md5_digest": "cb514478f7bb3c707797728cdd07e5e1",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.9.13",
"size": 253899,
"upload_time": "2025-01-10T22:54:17",
"upload_time_iso_8601": "2025-01-10T22:54:17.267614Z",
"url": "https://files.pythonhosted.org/packages/3d/18/302176545de65531f5a83a0b16af317a40f93d790cf405893f704bca8fdc/asyncdb-2.10.2-cp39-cp39-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f26c7e11a2ebc0241e98390b1f0815c352127fec7125b07d4778b5da1a8ddc07",
"md5": "fd5cb98f2a6ddb5954035bf2be2d2c54",
"sha256": "eb540208c909650b8ed5d41279297885f2a0483e7271eccb2c986433108cf6d9"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-pp310-pypy310_pp73-win_amd64.whl",
"has_sig": false,
"md5_digest": "fd5cb98f2a6ddb5954035bf2be2d2c54",
"packagetype": "bdist_wheel",
"python_version": "pp310",
"requires_python": ">=3.9.13",
"size": 245177,
"upload_time": "2025-01-10T22:54:18",
"upload_time_iso_8601": "2025-01-10T22:54:18.470556Z",
"url": "https://files.pythonhosted.org/packages/f2/6c/7e11a2ebc0241e98390b1f0815c352127fec7125b07d4778b5da1a8ddc07/asyncdb-2.10.2-pp310-pypy310_pp73-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3c4e9eb927c525325f3dc7e09160c21575d5c6364751096c104e026ebab48c80",
"md5": "42f2b03c9ee04b53480af7ac6057c77c",
"sha256": "997f1f31443d4367dfffdd02e71128585e56319e9f8a9b3db259301581a70095"
},
"downloads": -1,
"filename": "asyncdb-2.10.2-pp39-pypy39_pp73-win_amd64.whl",
"has_sig": false,
"md5_digest": "42f2b03c9ee04b53480af7ac6057c77c",
"packagetype": "bdist_wheel",
"python_version": "pp39",
"requires_python": ">=3.9.13",
"size": 245194,
"upload_time": "2025-01-10T22:54:19",
"upload_time_iso_8601": "2025-01-10T22:54:19.656809Z",
"url": "https://files.pythonhosted.org/packages/3c/4e/9eb927c525325f3dc7e09160c21575d5c6364751096c104e026ebab48c80/asyncdb-2.10.2-pp39-pypy39_pp73-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-10 22:53:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "phenobarbital",
"github_project": "asyncdb",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "asyncdb"
}