aiotinydb-2.0.0
توضیحات
asyncio compatibility shim for tinydb
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | aiotinydb-2.0.0 |
| نام | aiotinydb |
| نسخه کتابخانه | 2.0.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | ['d-k-bo <d-k-bo@mailbox.org>'] |
| نویسنده | - |
| ایمیل نویسنده | Pavel Pletenev <cpp.create@gmail.com> |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/aiotinydb/ |
| مجوز | - |
# aiotinydb
[](https://pypi.python.org/pypi/aiotinydb) [](https://pypi.python.org/pypi/aiotinydb) [](https://pypi.python.org/pypi/aiotinydb)  [](https://saythanks.io/to/ASMfreaK)
asyncio compatibility shim for [`TinyDB`](https://github.com/msiemens/tinydb)
Enables usage of TinyDB in asyncio-aware contexts without slow syncronous IO.
See documentation on compatible version of [`TinyDB`](https://tinydb.readthedocs.io/en/v4.7.0/).
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`.
```python
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](https://github.com/aiotinydb/aiotinydb/issues/6#issuecomment-1125343152) and [examples/processpool.py](examples/processpool.py) for an example).
## Middleware
Any middlewares you use **should be** async-aware. See example:
```python
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
```
نیازمندی
| مقدار | نام |
|---|---|
| - | tinydb>=4.7.0 |
| - | aiofiles>=0.8.0 |
| - | pytest>=7.0.1 |
| - | pytest-cov>=3.0.0 |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl aiotinydb-2.0.0:
pip install aiotinydb-2.0.0.whl
نصب پکیج tar.gz aiotinydb-2.0.0:
pip install aiotinydb-2.0.0.tar.gz