summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-aio-databases.spec679
-rw-r--r--sources1
3 files changed, 681 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..85d3f0e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/aio_databases-0.14.1.tar.gz
diff --git a/python-aio-databases.spec b/python-aio-databases.spec
new file mode 100644
index 0000000..62cb4fc
--- /dev/null
+++ b/python-aio-databases.spec
@@ -0,0 +1,679 @@
+%global _empty_manifest_terminate_build 0
+Name: python-aio-databases
+Version: 0.14.1
+Release: 1
+Summary: Async support for various databases
+License: MIT
+URL: https://github.com/klen/aio-databases
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/e5/8e/2ec7856e2ed504c240fa25b4d2076cad3edbedde40a4ca7bae2414269f8d/aio_databases-0.14.1.tar.gz
+BuildArch: noarch
+
+Requires: python3-asyncpg
+Requires: python3-aiopg
+Requires: python3-aiomysql
+Requires: python3-aiosqlite
+Requires: python3-aioodbc
+Requires: python3-triopg
+Requires: python3-trio_mysql
+
+%description
+# AIO-Databases
+
+The package gives you async 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/)
+
+## Features
+
+* Has no dependencies (except databases drivers)
+* Supports [asyncio](https://docs.python.org/3/library/asyncio.html) and [trio](https://github.com/python-trio/trio)
+* Supports [aiosqlite](https://github.com/omnilib/aiosqlite),
+ [aiomysql](https://github.com/aio-libs/aiomysql),
+ [aiopg](https://github.com/aio-libs/aiopg),
+ [asyncpg](https://github.com/MagicStack/asyncpg),
+ [triopg](https://github.com/python-trio/triopg),
+ [trio_mysql](https://github.com/python-trio/trio-mysql)
+* Manage pools of connections
+* Manage transactions
+
+## 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] # asyncio
+
+# To support MySQL
+$ pip install aio-databases[aiomysql] # asyncio
+$ pip install aio-databases[trio_mysql] # trio
+
+# To support PostgreSQL (choose one)
+$ pip install aio-databases[aiopg] # asyncio
+$ pip install aio-databases[asyncpg] # asyncio
+$ pip install aio-databases[triopg] # trio
+
+# To support ODBC (alpha state)
+$ pip install aio-databases[aioodbc] # asyncio
+```
+
+
+## Usage
+
+### Init a database
+
+```python
+ from aio_databases import Database
+
+ # Initialize a database
+ db = Database('sqlite:///:memory:') # with default driver
+
+ # Flesh out the driver
+ db = Database('aiosqlite:///:memory:', **driver_params)
+```
+
+### Setup a pool of connections (optional)
+
+Setup a pool of connections
+
+```python
+ # Initialize a database's pool
+ async def my_app_starts():
+ await db.connect()
+
+ # Close the pool
+ async def my_app_ends():
+ 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()
+```
+
+### Get a connection
+
+```python
+ # Acquire and release (on exit) a connection
+ async with db.connection():
+ await my_code()
+
+ # Acquire a connection only if it not exist
+ async with db.connection(False):
+ await my_code()
+```
+
+If a pool is setup it will be used
+
+### 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
+```
+
+* Iterate through rows one by one
+
+```python
+
+ async for rec in db.iterate('select name from users'):
+ print(rec)
+
+```
+
+### Manage connections
+
+By default the database opens and closes a connection for a query.
+
+```python
+ # Connection will be acquired and released for the query
+ await db.fetchone('select %s', 42)
+
+ # Connection will be acquired and released again
+ await db.fetchone('select %s', 77)
+```
+
+Manually open and close a connection
+
+```python
+
+ # Acquire a new connection object
+ async with db.connection():
+ # Only one connection will be used
+ await db.fetchone('select %s', 42)
+ await db.fetchone('select %s', 77)
+ # ...
+
+ # Acquire a new connection or use an existing
+ async with db.connection(False):
+ # ...
+```
+
+If there any connection already `db.method` would be using the current one
+```python
+ async with db.connection(): # connection would be acquired here
+ await db.fetchone('select %s', 42) # the connection is used
+ await db.fetchone('select %s', 77) # the connection is used
+
+ # the connection released there
+```
+
+### Manage transactions
+
+```python
+ # Start a tranction using the current connection
+ async with db.transaction() as trans1:
+ # do some work ...
+
+ async with db.transaction() as trans2:
+ # do some work ...
+ await trans2.rollback()
+
+ # unnessesary, the transaction will be commited on exit from the
+ # current context
+
+ await trans1.commit()
+
+ # Create a new connection and start a transaction
+ async with db.tranction(True) as trans:
+ # do some work ...
+```
+
+## 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)
+
+
+%package -n python3-aio-databases
+Summary: Async support for various databases
+Provides: python-aio-databases
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-aio-databases
+# AIO-Databases
+
+The package gives you async 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/)
+
+## Features
+
+* Has no dependencies (except databases drivers)
+* Supports [asyncio](https://docs.python.org/3/library/asyncio.html) and [trio](https://github.com/python-trio/trio)
+* Supports [aiosqlite](https://github.com/omnilib/aiosqlite),
+ [aiomysql](https://github.com/aio-libs/aiomysql),
+ [aiopg](https://github.com/aio-libs/aiopg),
+ [asyncpg](https://github.com/MagicStack/asyncpg),
+ [triopg](https://github.com/python-trio/triopg),
+ [trio_mysql](https://github.com/python-trio/trio-mysql)
+* Manage pools of connections
+* Manage transactions
+
+## 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] # asyncio
+
+# To support MySQL
+$ pip install aio-databases[aiomysql] # asyncio
+$ pip install aio-databases[trio_mysql] # trio
+
+# To support PostgreSQL (choose one)
+$ pip install aio-databases[aiopg] # asyncio
+$ pip install aio-databases[asyncpg] # asyncio
+$ pip install aio-databases[triopg] # trio
+
+# To support ODBC (alpha state)
+$ pip install aio-databases[aioodbc] # asyncio
+```
+
+
+## Usage
+
+### Init a database
+
+```python
+ from aio_databases import Database
+
+ # Initialize a database
+ db = Database('sqlite:///:memory:') # with default driver
+
+ # Flesh out the driver
+ db = Database('aiosqlite:///:memory:', **driver_params)
+```
+
+### Setup a pool of connections (optional)
+
+Setup a pool of connections
+
+```python
+ # Initialize a database's pool
+ async def my_app_starts():
+ await db.connect()
+
+ # Close the pool
+ async def my_app_ends():
+ 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()
+```
+
+### Get a connection
+
+```python
+ # Acquire and release (on exit) a connection
+ async with db.connection():
+ await my_code()
+
+ # Acquire a connection only if it not exist
+ async with db.connection(False):
+ await my_code()
+```
+
+If a pool is setup it will be used
+
+### 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
+```
+
+* Iterate through rows one by one
+
+```python
+
+ async for rec in db.iterate('select name from users'):
+ print(rec)
+
+```
+
+### Manage connections
+
+By default the database opens and closes a connection for a query.
+
+```python
+ # Connection will be acquired and released for the query
+ await db.fetchone('select %s', 42)
+
+ # Connection will be acquired and released again
+ await db.fetchone('select %s', 77)
+```
+
+Manually open and close a connection
+
+```python
+
+ # Acquire a new connection object
+ async with db.connection():
+ # Only one connection will be used
+ await db.fetchone('select %s', 42)
+ await db.fetchone('select %s', 77)
+ # ...
+
+ # Acquire a new connection or use an existing
+ async with db.connection(False):
+ # ...
+```
+
+If there any connection already `db.method` would be using the current one
+```python
+ async with db.connection(): # connection would be acquired here
+ await db.fetchone('select %s', 42) # the connection is used
+ await db.fetchone('select %s', 77) # the connection is used
+
+ # the connection released there
+```
+
+### Manage transactions
+
+```python
+ # Start a tranction using the current connection
+ async with db.transaction() as trans1:
+ # do some work ...
+
+ async with db.transaction() as trans2:
+ # do some work ...
+ await trans2.rollback()
+
+ # unnessesary, the transaction will be commited on exit from the
+ # current context
+
+ await trans1.commit()
+
+ # Create a new connection and start a transaction
+ async with db.tranction(True) as trans:
+ # do some work ...
+```
+
+## 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)
+
+
+%package help
+Summary: Development documents and examples for aio-databases
+Provides: python3-aio-databases-doc
+%description help
+# AIO-Databases
+
+The package gives you async 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/)
+
+## Features
+
+* Has no dependencies (except databases drivers)
+* Supports [asyncio](https://docs.python.org/3/library/asyncio.html) and [trio](https://github.com/python-trio/trio)
+* Supports [aiosqlite](https://github.com/omnilib/aiosqlite),
+ [aiomysql](https://github.com/aio-libs/aiomysql),
+ [aiopg](https://github.com/aio-libs/aiopg),
+ [asyncpg](https://github.com/MagicStack/asyncpg),
+ [triopg](https://github.com/python-trio/triopg),
+ [trio_mysql](https://github.com/python-trio/trio-mysql)
+* Manage pools of connections
+* Manage transactions
+
+## 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] # asyncio
+
+# To support MySQL
+$ pip install aio-databases[aiomysql] # asyncio
+$ pip install aio-databases[trio_mysql] # trio
+
+# To support PostgreSQL (choose one)
+$ pip install aio-databases[aiopg] # asyncio
+$ pip install aio-databases[asyncpg] # asyncio
+$ pip install aio-databases[triopg] # trio
+
+# To support ODBC (alpha state)
+$ pip install aio-databases[aioodbc] # asyncio
+```
+
+
+## Usage
+
+### Init a database
+
+```python
+ from aio_databases import Database
+
+ # Initialize a database
+ db = Database('sqlite:///:memory:') # with default driver
+
+ # Flesh out the driver
+ db = Database('aiosqlite:///:memory:', **driver_params)
+```
+
+### Setup a pool of connections (optional)
+
+Setup a pool of connections
+
+```python
+ # Initialize a database's pool
+ async def my_app_starts():
+ await db.connect()
+
+ # Close the pool
+ async def my_app_ends():
+ 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()
+```
+
+### Get a connection
+
+```python
+ # Acquire and release (on exit) a connection
+ async with db.connection():
+ await my_code()
+
+ # Acquire a connection only if it not exist
+ async with db.connection(False):
+ await my_code()
+```
+
+If a pool is setup it will be used
+
+### 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
+```
+
+* Iterate through rows one by one
+
+```python
+
+ async for rec in db.iterate('select name from users'):
+ print(rec)
+
+```
+
+### Manage connections
+
+By default the database opens and closes a connection for a query.
+
+```python
+ # Connection will be acquired and released for the query
+ await db.fetchone('select %s', 42)
+
+ # Connection will be acquired and released again
+ await db.fetchone('select %s', 77)
+```
+
+Manually open and close a connection
+
+```python
+
+ # Acquire a new connection object
+ async with db.connection():
+ # Only one connection will be used
+ await db.fetchone('select %s', 42)
+ await db.fetchone('select %s', 77)
+ # ...
+
+ # Acquire a new connection or use an existing
+ async with db.connection(False):
+ # ...
+```
+
+If there any connection already `db.method` would be using the current one
+```python
+ async with db.connection(): # connection would be acquired here
+ await db.fetchone('select %s', 42) # the connection is used
+ await db.fetchone('select %s', 77) # the connection is used
+
+ # the connection released there
+```
+
+### Manage transactions
+
+```python
+ # Start a tranction using the current connection
+ async with db.transaction() as trans1:
+ # do some work ...
+
+ async with db.transaction() as trans2:
+ # do some work ...
+ await trans2.rollback()
+
+ # unnessesary, the transaction will be commited on exit from the
+ # current context
+
+ await trans1.commit()
+
+ # Create a new connection and start a transaction
+ async with db.tranction(True) as trans:
+ # do some work ...
+```
+
+## 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)
+
+
+%prep
+%autosetup -n aio-databases-0.14.1
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-aio-databases -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.14.1-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..2c41f54
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+25d5fd93d59268857b68717f498c9c21 aio_databases-0.14.1.tar.gz