Skip to main content

Tinydb CRUD wrapper for table

Project description

Tinydb Helper

A Tinydb crud wrapper that make crud operations a breeze

Installation

You can install the package using pip:

pip install tinydb-helper

Usage

This package will install Tinydb

from tinydb_helper.helper import Table
from tinydb import TinyDB
import time

def main() -> None:
    db = TinyDB("db.json")
    timestamp = str(int(time.time()))

    # Exemple creating project table with custom primary key using default primary key generator 
    project = Table(db=db, table="project", primary_key="proj_id")
     
    # Example creating person table with custom primary key generator
    person = Table(db=db, table="person", key_gen=lambda: timestamp)

    # Example inserting a few record in person and project tables
    for i in range(4):
        project.insert(dict(name=f"test-{i}", year=f"{2004 + i}"), id=str(i + 1))
        person.insert(dict(first=f"first-{i}", year=f"{2004 + i}", id=str(i + 1)))

    # Exemple get all object from table person
    person.all()

    # Exemple find person object matching primary key field equal to "0"
    person.find(id="0")

    # Exemple update person object matching primary key field equal to "0" 
    person.update(id="0", item=dict(test='pass'))

     # Exemple delete person object matching primary key field equal to "0"
    person.delete(id="0")

if __name__ == "__main__":
    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

tinydb_helper-0.1.2.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

tinydb_helper-0.1.2-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file tinydb_helper-0.1.2.tar.gz.

File metadata

  • Download URL: tinydb_helper-0.1.2.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for tinydb_helper-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3cfdca740bfea7b2a3eaaca4585661c3f21a05756740f03e0c061baf7ab53a44
MD5 741e20dbbb0c2dd91bf0b90ebd17f2de
BLAKE2b-256 2578b001ad3579df9fb2ae0243d8a7d65cb6353d8e0d93ab0e05525c924e7735

See more details on using hashes here.

File details

Details for the file tinydb_helper-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: tinydb_helper-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1025-azure

File hashes

Hashes for tinydb_helper-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3be8cd55914f820a0c4eceefec542ae51aff6200b16debd31512d7f5942b80a2
MD5 8b4f63ae11aecbab54ae7c03281dbb1a
BLAKE2b-256 c4e1dc36b71b237923ee599001df54a5c96b449f7b784978834619e3bcea2659

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