Metadata-Version: 2.1
Name: aio-databases
Version: 0.0.17
Summary: Async Support for various databases
Home-page: https://github.com/klen/aio-databases
Author: Kirill Klenov
Author-email: horneds@gmail.com
License: MIT
Project-URL: Documentation, https://github.com/klen/aio-databases
Project-URL: Source code, https://github.com/klen/aio-databases
Project-URL: Issue tracker, https://github.com/klen/aio-databases/issues
Description: # AIO-Databases
        
        The package gives you asycio support for a range of databases (SQLite,
        PostgreSQL, MySQL).
        
        [![Tests Status](https://github.com/klen/aio-databases/workflows/tests/badge.svg)](https://github.com/klen/aio-databases/actions)
        [![PYPI Version](https://img.shields.io/pypi/v/aio-databases)](https://pypi.org/project/aio-databases/)
        [![Python Versions](https://img.shields.io/pypi/pyversions/aio-databases)](https://pypi.org/project/aio-databases/)
        
        
        ## Requirements
        
        * python >= 3.7
        
        ## Installation
        
        **aio-databases** should be installed using pip:
        
        ```shell
        $ pip install aio-databases
        ```
        
        You have to choose and install the required database drivers with:
        
        ```shell
        # To support SQLite
        $ pip install aio-databases[aiosqlite]
        
        # To support MySQL
        $ pip install aio-databases[aiomysql]
        
        # To support PostgreSQL (choose one)
        $ pip install aio-databases[aiopg]
        $ pip install aio-databases[asyncpg]
        ```
        
        
        ## Usage
        
        * Init a database
        
        ```python
            from aio_databases import Database
        
            db = Database('sqlite:///:memory:')
        ```
        
        * Prepare the database to work
        
        ```python
            async def my_app_starts():
                # Initialize a database's pool
                await db.connect()
        
            async def my_app_ends():
                # Close pool/connections
                await db.disconnect()
        
            # As an alternative users are able to use the database
            # as an async context manager
        
            async with db:
                await my_main_coroutine()
        ```
        
        * Run SQL queries
        
        ```python
            await db.execute('select $1', '1')
            await db.executemany('select $1', '1', '2', '3')
        
            records = await db.fetchall('select (2 * $1) res', 2)
            assert records == [(4,)]
        
            record = await db.fetchone('select (2 * $1) res', 2)
            assert record == (4,)
            assert record['res'] == 4
        
            result = await db.fetchval('select 2 * $1', 2)
            assert result == 4
        ```
        
        * Use transactions
        
        ```python
            async with db.transaction() as trans1:
                # do some work ...
        
                async with db.transaction() as trans2:
                    # do some work ...
                    await trans2.rollback()
        ```
        
        ## Bug tracker
        
        If you have any suggestions, bug reports or annoyances please report them to
        the issue tracker at https://github.com/klen/aio-databases/issues
        
        
        ## Contributing
        
        Development of the project happens at: https://github.com/klen/aio-databases
        
        
        ## License
        
        Licensed under a [MIT License](http://opensource.org/licenses/MIT)
        
Keywords: asyncio,databases,mysql,sqlite,postgres,postgresql
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Framework :: AsyncIO
Classifier: Framework :: Trio
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: asyncpg
Provides-Extra: aiomysql
Provides-Extra: aiosqlite
Provides-Extra: tests
