Skip to content

Releases: Privex/python-db

0.9.0 - AsyncIO support for wrapper + builder, plus small improvements

09 Dec 03:28
Compare
Choose a tag to compare

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 :)