All Projects → ASMfreaK → aiotinydb

ASMfreaK / aiotinydb

Licence: other
asyncio compatibility shim for tinydb

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to aiotinydb

Tinvest
Тинькофф Инвестиции, tinkoff, python, aiohttp, requests, pydantic
Stars: ✭ 115 (+173.81%)
Mutual labels:  pypi, asyncio
duckpy
A simple Python library for searching on DuckDuckGo.
Stars: ✭ 20 (-52.38%)
Mutual labels:  pypi, asyncio
thanker
Don't be a wanker, be a thanker! Automatically give thanks to Pypi packages you use in your project.
Stars: ✭ 25 (-40.48%)
Mutual labels:  pypi, asyncio
feedsearch-crawler
Crawl sites for RSS, Atom, and JSON feeds.
Stars: ✭ 23 (-45.24%)
Mutual labels:  pypi, asyncio
Pytradfri
IKEA Trådfri/Tradfri API. Control and observe your lights from Python. Examples available. On pypi. Sans-io.
Stars: ✭ 778 (+1752.38%)
Mutual labels:  pypi, asyncio
Pyatv
A python client library for the Apple TV
Stars: ✭ 322 (+666.67%)
Mutual labels:  pypi, asyncio
asyncio-socks-server
A SOCKS proxy server implemented with the powerful python cooperative concurrency framework asyncio.
Stars: ✭ 154 (+266.67%)
Mutual labels:  pypi, asyncio
Pymarketcap
Python3 API wrapper and web scraper for https://coinmarketcap.com
Stars: ✭ 73 (+73.81%)
Mutual labels:  pypi, asyncio
Purerpc
Asynchronous pure Python gRPC client and server implementation supporting asyncio, uvloop, curio and trio
Stars: ✭ 125 (+197.62%)
Mutual labels:  pypi, asyncio
psm
Pypi Source Manager: fast switch between different Pypi Source: Pypi, double, aliyun
Stars: ✭ 31 (-26.19%)
Mutual labels:  pypi
MicroExpress
A micro web server framework on top of Swift NIO
Stars: ✭ 125 (+197.62%)
Mutual labels:  asyncio
pipx
Install and Run Python Applications in Isolated Environments
Stars: ✭ 5,698 (+13466.67%)
Mutual labels:  pypi
pyutilib
A collection of general Python utilities, including logging and file IO, subprocess management, plugin systems, and workflow management.
Stars: ✭ 28 (-33.33%)
Mutual labels:  pypi
async cron
crontab for python,with asyncio
Stars: ✭ 23 (-45.24%)
Mutual labels:  asyncio
pip-download
A wrapper for pip download in offline scenario.
Stars: ✭ 22 (-47.62%)
Mutual labels:  pypi
trellio
Python3 asyncio based microframework for microservice architecture
Stars: ✭ 19 (-54.76%)
Mutual labels:  asyncio
pystyle
The source of my Python library, pystyle.
Stars: ✭ 158 (+276.19%)
Mutual labels:  pypi
ocflib
Python libraries for account and server management
Stars: ✭ 13 (-69.05%)
Mutual labels:  pypi
knxmap
KNXnet/IP scanning and auditing tool for KNX home automation installations.
Stars: ✭ 97 (+130.95%)
Mutual labels:  asyncio
aioneo4j
asyncio client for neo4j
Stars: ✭ 29 (-30.95%)
Mutual labels:  asyncio

aiotinydb

PyPI PyPI PyPI Build Status Say Thanks!

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 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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].