Skip to content

Commit

Permalink
0.9.0 - AsyncIO support for wrapper + builder
Browse files Browse the repository at this point in the history
**Updates and Improvements**
    - Refactored `SqliteWrapper._should_zip` into a standalone function for sharing between other classes and methods.

**New additions**

 - New dependencies: `aiosqlite`, `async-property` and `nest_asyncio`
 - New class `db.base.GenericAsyncDBWrapper` - an abstract base class for AsyncIO database wrappers
 - New class `db.query.asyncx.base.BaseAsyncQueryBuilder` - an abstract base class for AsyncIO query builders

- New protocol types in `db.types`:
    - `GenericAsyncCursor` - a protocol which covers any class which implements the Python DB API (PEP 249) for cursors, with all methods being coroutines (async def).
    - `GenericAsyncConnection` - a protocol which covers any class which implements the Python DB API (PEP 249) for DB connections, with all methods being coroutines (async def).

 - AsyncIO Sqlite3 support:
    - `db.sqlite.SqliteAsyncWrapper` uses `aiosqlite` to provide asynchronous wrapper methods for interacting with Sqlite3 databases asynchronously.
    - `db.query.asyncx.sqlite.SqliteAsyncQueryBuilder` is a query builder for Sqlite3 which uses `aiosqlite` to implement async methods for executing the built queries and fetching the results

**Unit testing**

 - Added `pytest-asyncio` as a development dependency, allowing for asynchronous unit tests

- Changes to `tests/base.py`:
    - Created class `_TestAsyncWrapperMixin` - an async version of `_TestWrapperMixin`
    - Created class `ExampleAsyncWrapper` - an async version of `ExampleWrapper`
    - Refactored `_TestWrapperMixin.example_users` into a module variable so that it can be shared by other classes.

 - Created `tests/test_async.py`
    - Uses `pytest-asyncio` for running async unit test functions
    - Unit tests to cover the async class `SqliteAsyncWrapper` (based on the unit tests in `test_sqlite_wrapper.py`)
    - Unit tests to cover the async class `SqliteAsyncQueryBuilder` (based on the unit tests in `test_sqlite_builder.py`)

**This covers all notable changes and additions. There may possibly be other small changes and improvements too :)**
  • Loading branch information
Someguy123 committed Dec 9, 2019
1 parent 38b7b3e commit 7048058
Show file tree
Hide file tree
Showing 17 changed files with 2,346 additions and 98 deletions.
8 changes: 6 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ coverage = "*"
codecov = "*"
pytest = "*"
pytest-cov = "*"
privex-helpers = {extras = ["setuppy"],version = ">=2.3.0"}
privex-helpers = {extras = ["setuppy"],version = ">=2.6.0"}
sphinx-autobuild = ">=0.7.1"
restructuredtext-lint = ">=1.3.0"
sphinx-rtd-theme = ">=0.4.3"
Expand All @@ -20,11 +20,15 @@ python-dotenv = "*"
[packages]
privex-loghelper = "*"
python-dateutil = "*"
privex-helpers = ">=2.3.0"
privex-helpers = ">=2.6.0"
pytz = "*"
mysqlclient = "*"
psycopg2 = "*"
typing-extensions = "*"
aiosqlite = "*"
pytest-asyncio = "*"
async-property = "*"
nest-asyncio = "*"

[requires]
python_version = "3.8"
222 changes: 168 additions & 54 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7048058

Please sign in to comment.