asyncdb


Nameasyncdb JSON
Version 2.11.1 PyPI version JSON
download
home_pagehttps://github.com/phenobarbital/asyncdb
SummaryLibrary for Asynchronous data source connections Collection of asyncio drivers.
upload_time2025-02-25 23:33:08
maintainerNone
docs_urlNone
authorJesus Lara
requires_python>=3.10.0
licenseBSD
keywords asyncio asyncpg aioredis aiomcache cassandra scylladb
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.10.0",
    "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.11.1",
    "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": null,
            "digests": {
                "blake2b_256": "2591196004f79c0ab5738773a49b993f0dd4ce8ba47aee6a5e6979d360b59906",
                "md5": "09448b5365b63820eed2eef2147319fb",
                "sha256": "ab6e5f57a6812504bff816c808b21dd0c203c4f5667abce9a6e4ac8feb3a4c58"
            },
            "downloads": -1,
            "filename": "asyncdb-2.11.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "09448b5365b63820eed2eef2147319fb",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10.0",
            "size": 801843,
            "upload_time": "2025-02-25T23:33:08",
            "upload_time_iso_8601": "2025-02-25T23:33:08.961667Z",
            "url": "https://files.pythonhosted.org/packages/25/91/196004f79c0ab5738773a49b993f0dd4ce8ba47aee6a5e6979d360b59906/asyncdb-2.11.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "08de04895f7b7fe815efe0f194fa12530517144b4deba822dd2c8d8617cc7bfc",
                "md5": "0118c935076932c3614c10f3312ecfa6",
                "sha256": "23976fd08167dfe1d58966d1d86bf95c6af85b88ba2185a5a312aee4c7305d38"
            },
            "downloads": -1,
            "filename": "asyncdb-2.11.1-cp310-cp310-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "0118c935076932c3614c10f3312ecfa6",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": ">=3.10.0",
            "size": 256768,
            "upload_time": "2025-02-25T23:33:17",
            "upload_time_iso_8601": "2025-02-25T23:33:17.609898Z",
            "url": "https://files.pythonhosted.org/packages/08/de/04895f7b7fe815efe0f194fa12530517144b4deba822dd2c8d8617cc7bfc/asyncdb-2.11.1-cp310-cp310-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7e4cbc43af2e761188631cb4f87395d837e2a525f49c32d0296d8d35cb912361",
                "md5": "63508ac08ed6aea50f83365bf5601816",
                "sha256": "6f9693f251a9917df626da78cfc5df8c0a0a7ebe79deee6cc58fc426e4aa596f"
            },
            "downloads": -1,
            "filename": "asyncdb-2.11.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "63508ac08ed6aea50f83365bf5601816",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10.0",
            "size": 861618,
            "upload_time": "2025-02-25T23:33:12",
            "upload_time_iso_8601": "2025-02-25T23:33:12.216520Z",
            "url": "https://files.pythonhosted.org/packages/7e/4c/bc43af2e761188631cb4f87395d837e2a525f49c32d0296d8d35cb912361/asyncdb-2.11.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f79c5e7308779a99bd801d0df387189f4203cb0247770dadd90327a0f9537895",
                "md5": "964608ecc50dc8f6e760945290a7e816",
                "sha256": "5b5c84e317d117d58e78407ca0f3d859ae691269a3325be96ab865e67b944cf7"
            },
            "downloads": -1,
            "filename": "asyncdb-2.11.1-cp311-cp311-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "964608ecc50dc8f6e760945290a7e816",
            "packagetype": "bdist_wheel",
            "python_version": "cp311",
            "requires_python": ">=3.10.0",
            "size": 257263,
            "upload_time": "2025-02-25T23:33:22",
            "upload_time_iso_8601": "2025-02-25T23:33:22.654207Z",
            "url": "https://files.pythonhosted.org/packages/f7/9c/5e7308779a99bd801d0df387189f4203cb0247770dadd90327a0f9537895/asyncdb-2.11.1-cp311-cp311-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "dc08a96350189b452849c12d6430db80e4b9c91c4a8bfa82033826fdd569293d",
                "md5": "c375ec47a23040a48770771b378b82a0",
                "sha256": "7b35a273b6fc9998589995f731b0f02e08cdc08e33bcc7da304f9ae7a2fa4392"
            },
            "downloads": -1,
            "filename": "asyncdb-2.11.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "c375ec47a23040a48770771b378b82a0",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.10.0",
            "size": 933239,
            "upload_time": "2025-02-25T23:33:13",
            "upload_time_iso_8601": "2025-02-25T23:33:13.648903Z",
            "url": "https://files.pythonhosted.org/packages/dc/08/a96350189b452849c12d6430db80e4b9c91c4a8bfa82033826fdd569293d/asyncdb-2.11.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d01eb0378b27a795ee003529415154d8827975b0f779859a3768274dfaef5092",
                "md5": "3d0d8725de462efdc304ad7be5a2ec19",
                "sha256": "5b65c5dd68e7bb2e9f68cf3ff20fda2dd7ab716a763406821f7d2e55cbb3259c"
            },
            "downloads": -1,
            "filename": "asyncdb-2.11.1-cp312-cp312-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "3d0d8725de462efdc304ad7be5a2ec19",
            "packagetype": "bdist_wheel",
            "python_version": "cp312",
            "requires_python": ">=3.10.0",
            "size": 254980,
            "upload_time": "2025-02-25T23:33:23",
            "upload_time_iso_8601": "2025-02-25T23:33:23.983321Z",
            "url": "https://files.pythonhosted.org/packages/d0/1e/b0378b27a795ee003529415154d8827975b0f779859a3768274dfaef5092/asyncdb-2.11.1-cp312-cp312-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1bbbeca8681d26a8fae2e14611643308b85fd67624798b46a494a1a0e337eebd",
                "md5": "e8a4d44c4359ad47e2253f9d1fb8fee7",
                "sha256": "a5be09029a55303d22c73579fdaf31b25db58ef6519f63377a6658c765814386"
            },
            "downloads": -1,
            "filename": "asyncdb-2.11.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "e8a4d44c4359ad47e2253f9d1fb8fee7",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": ">=3.10.0",
            "size": 910764,
            "upload_time": "2025-02-25T23:33:15",
            "upload_time_iso_8601": "2025-02-25T23:33:15.805548Z",
            "url": "https://files.pythonhosted.org/packages/1b/bb/eca8681d26a8fae2e14611643308b85fd67624798b46a494a1a0e337eebd/asyncdb-2.11.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "db702d6bacd8610a63c3b946392e89a52ffa9f8eec45d9d1f68b5f76c69ab84d",
                "md5": "7a63f68cfa16424f41dd2082feeed247",
                "sha256": "b15ab85e959cd758db907f22c90cbb3339408e9828af704e087965a0dd549aec"
            },
            "downloads": -1,
            "filename": "asyncdb-2.11.1-cp313-cp313-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "7a63f68cfa16424f41dd2082feeed247",
            "packagetype": "bdist_wheel",
            "python_version": "cp313",
            "requires_python": ">=3.10.0",
            "size": 253689,
            "upload_time": "2025-02-25T23:33:26",
            "upload_time_iso_8601": "2025-02-25T23:33:26.115507Z",
            "url": "https://files.pythonhosted.org/packages/db/70/2d6bacd8610a63c3b946392e89a52ffa9f8eec45d9d1f68b5f76c69ab84d/asyncdb-2.11.1-cp313-cp313-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4ae5fd725be01db09bafcac7c0bd950bef610842d207c5c53bea6792ffc642a8",
                "md5": "7563827840cb96dc233f7b303da4a6d5",
                "sha256": "7a4565346e9e233de241ffc7217598bd50f12a263e28beec6ab3ef93156c0c4f"
            },
            "downloads": -1,
            "filename": "asyncdb-2.11.1-pp310-pypy310_pp73-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "7563827840cb96dc233f7b303da4a6d5",
            "packagetype": "bdist_wheel",
            "python_version": "pp310",
            "requires_python": ">=3.10.0",
            "size": 248828,
            "upload_time": "2025-02-25T23:33:27",
            "upload_time_iso_8601": "2025-02-25T23:33:27.384709Z",
            "url": "https://files.pythonhosted.org/packages/4a/e5/fd725be01db09bafcac7c0bd950bef610842d207c5c53bea6792ffc642a8/asyncdb-2.11.1-pp310-pypy310_pp73-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-25 23:33:08",
    "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"
}
        
Elapsed time: 0.39344s