Skip to main content

Yet Another Async TinyDB

Reason this release was yanked:

Bad Specification

Project description

logo

What's This?

"An asynchronous IO version of TinyDB based on aiofiles."

Almost every method is asynchronous. And it's based on TinyDB 4.7.0+.
I will try to keep up with the latest version of TinyDB.

Since I modified it in just a few hours, I'm not sure if it's stable enough for production.
But hey! It passed all the tests anyways.

A few extra minor differences from the original TinyDB:

  • lazy-load: When access-mode is set to 'r', FileNotExistsError is not raised until the first read operation.
  • ujson: Using ujson instead of json. Some arguments aren't compatible with json

How to use IT?

Installation

pip install async-tinydb

Importing

from asynctinydb import TinyDB, where

Basically, all you need to do is insert an await before every method that needs IO.

Notice that some parts of the code are blocking, for example when calling len() on TinyDB or Table Objects.

Example Codes:

import asyncio
from asynctinydb import TinyDB, Query

async def main():
    db = TinyDB('test.json')
    await db.insert({"answer": 42})
    print(await db.search(Query().answer == 42))  # >>> [{'answer': 42}] 

asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

async-tinydb-1.0.0.tar.gz (21.5 kB view hashes)

Uploaded Source

Built Distribution

async_tinydb-1.0.0-py3-none-any.whl (23.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page