Skip to main content

tinydb-constraint

PyPI version shields.io PyPI license

Apply constraints before inserting and updating TinyDB records.

Installation

Method 1:

$ pip install tinydb-constraint

Method 2:

  • Clone the project from GitHub
  • Get poetry and poetry install tinydb-constraint --path PATH/TO/TINYDB/CONSTRAINT

Usage

>>> from tinydb import TinyDB
>>> from tinydb_constraint import ConstraintTable
>>> from datetime import datetime
>>> TinyDB.table_class = ConstraintTable
>>> db = TinyDB('db.json')
>>> db.set_schema({
...     'record_id': int,
...     'modified': datetime
... })
>>> db.schema
{
    'record_id': Constraint(type_=int, unique=False, not_null=False),
    'modified': Constraint(type_=datetime.datetime, unique=False, not_null=False)
}

Note

I haven't modified the serialization yet, so datetime type will actually produce datetime.isoformat(), and to set datetime, you have to pass a dateutil.parser.parse()-parsable string.

Advanced usage

Database schema is also settable via Constraint object.

>>> from tinydb_constraint import Constraint
>>> db.set_schema({
...     'user_id': Constraint(type_=int, unique=True, not_null=True)
... })

If you want to disable certain string sanitization features, like stripping spaces or checking if string can be converted to datetime, this can be done by setting environmental variables.

TINYDB_SANITIZE=0
TINYDB_DATETIME=0

Plan

  • Add ForeignKey constraints.
  • tinydb-viewer - View records generated from TinyDB and alike (e.g. list of dictionaries.)

Metadata

Release files for tinydb-constraint 0.1.7.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tinydb-constraint 0.1.7.1
File Size Uploaded Provenance Actions
tinydb-constraint-0.1.7.1.tar.gz 5.6 kB Without provenance Details for tinydb-constraint-0.1.7.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tinydb-constraint 0.1.7.1
File Interpreter ABI Platform Actions
tinydb_constraint-0.1.7.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for tinydb_constraint-0.1.7.1-py2.py3-none-any.whl

Total release size: 20.8 kB

Release files / tinydb-constraint-0.1.7.1.tar.gz

Download URL tinydb-constraint-0.1.7.1.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fe9e1457a83ed81709f167d1a4d6cdaa29705d6add53bedae8f7be1477e6ff17
BLAKE2b-256 checksum
How to use checksums
67655b4b662dc10dee76b4d6ad5077e2a10bb8865cee7db1afaa4a911f2f7fd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.11.5 CPython/3.7.0 Darwin/17.7.0

Release files / tinydb_constraint-0.1.7.1-py2.py3-none-any.whl

Download URL tinydb_constraint-0.1.7.1-py2.py3-none-any.whl
Size 15.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0579cf0e4c4efe8643323cd01828684ee0089de6a77830d3266b32390497a94a
BLAKE2b-256 checksum
How to use checksums
4bb166d3c01f79948f4194003ffa8e14f21daed320b3b7152f8e37561728fb96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.11.5 CPython/3.7.0 Darwin/17.7.0

Security for tinydb-constraint 0.1.7.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page