aiotinydb
asyncio compatibility shim for TinyDB
Enables usage of TinyDB in asyncio-aware contexts without slow syncronous IO.
See documentation on compatible version of TinyDB.
Basically all API calls from TinyDB are supported in AIOTinyDB. With the following exceptions: you should not use basic with syntax and close functions. Instead, you should use async with.
import asyncio
from aiotinydb import AIOTinyDB
async def test():
async with AIOTinyDB('test.json') as db:
db.insert(dict(counter=1))
loop = asyncio.new_event_loop()
loop.run_until_complete(test())
loop.close()
CPU-bound operations like db.search(), db.update() etc. are executed synchronously and may block the event loop under heavy load. Use multiprocessing if that's an issue (see #6 and examples/processpool.py for an example).
Middleware
Any middlewares you use should be async-aware. See example:
from tinydb.middlewares import CachingMiddleware as VanillaCachingMiddleware
from aiotinydb.middleware import AIOMiddleware
class CachingMiddleware(VanillaCachingMiddleware, AIOMiddlewareMixin):
"""
Async-aware CachingMiddleware. For more info read
docstring for `tinydb.middlewares.CachingMiddleware`
"""
pass
If middleware requires some special handling on entry and exit, override __aenter__ and __aexit__.
Concurrent database access
Instances of AIOTinyDB support database access from multiple coroutines.
On unix-like systems, it's also possible to access one database concurrently from multiple processes when using AIOJSONStorage (the default) or AIOImmutableJSONStorage.
Installation
pip install aiotinydb
Metadata
Release files for aiotinydb 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aiotinydb-2.0.0.tar.gz | 15.7 kB | Without provenance | Details for aiotinydb-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiotinydb-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for aiotinydb-2.0.0-py3-none-any.whl |
Total release size: 28.9 kB
Release files / aiotinydb-2.0.0.tar.gz
| Download URL | aiotinydb-2.0.0.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
19baa7225b205c4956a440da12e237626aea9345061210c739198f5d753a98f6
|
|
BLAKE2b-256 checksum How to use checksums |
89304262d5ddbffeb19afa263b35485468a2d12fbf43f7b8d31b3e540aee58b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.1
|
Release files / aiotinydb-2.0.0-py3-none-any.whl
| Download URL | aiotinydb-2.0.0-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1009fcbbc4315eb250edfe8fded28f1b01598be222b86d6929fb95847da21696
|
|
BLAKE2b-256 checksum How to use checksums |
b017692561aec4aa935031667c742a3641e6f71ebc7237036811ebb8031c5ba9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.28.1
|
Security for aiotinydb 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.