Skip to main content

Atomic transactions for TinyDB

Project description

TinyDB __  _                                   __
      / /_(_)__  __ _________ _______  _______/ /
     / __/ / _ \/ // / __/ -_) __/ _ \/ __/ _  /
     \__/_/_//_/\_, /_/  \__/\__/\___/_/  \_,_/
               /___/

Supported Pythons: 3.5+

Tinyrecord is a library which implements atomic transaction support for the TinyDB NoSQL database. It uses a record-first then execute architecture which allows us to minimize the time that we are within a thread lock. Usage example:

from tinydb import TinyDB, where
from tinyrecord import transaction

table = TinyDB('db.json').table('table')
with transaction(table) as tr:
    # insert a new record
    tr.insert({'username': 'john'})
    # update records matching a query
    tr.update({'invalid': True}, where('username') == 'john')
    # delete records
    tr.remove(where('invalid') == True)
    # update using a function
    tr.update(updater, where(...))
    # insert many items
    tr.insert_multiple(documents)

Note that due to performance reasons you cannot view the data within a transaction unless you’ve comitted. You will have to call operations on the transaction object and not the database itself. Since tinyrecord works with dictionaries and the latest API, it will only support the latest version (4.x).

Installation is as simple as pip install tinyrecord.

https://travis-ci.org/eugene-eeo/tinyrecord.svg?branch=master

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

tinyrecord-0.2.0.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file tinyrecord-0.2.0.tar.gz.

File metadata

  • Download URL: tinyrecord-0.2.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.2

File hashes

Hashes for tinyrecord-0.2.0.tar.gz
Algorithm Hash digest
SHA256 eb6dc23601be359ee00f5a3d31a46adf3bad0a16f8d60af216cd67982ca75cf4
MD5 cbaae3f4599b12e3bea67ca4a75eca99
BLAKE2b-256 d86ca004d025d9bf1d8af014fd6f22bd6e49e4533d6fbac54f7d4ae7acb3ef5f

See more details on using hashes here.

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