Skip to main content

A lightweight JSON document database with field-level operation queuing and concurrency support

Project description

StarDDB (Star Document-database)

"Shoot for the moon. Even if you miss, you'll land among the stars." - Norman Vincent Peale

StarDDB is a simple to use, lightweight (single file implementation) DB for efficient JSON-like storage management.

Features

  • Concurrency support via field-level operation queuing
  • Easy-to-use API
  • Automatic background persistence
  • Nested document support
  • Thread-safe (Python) / Event-loop safe (Node.js)

Installation

pip install starddb

Quick Start

from stardb import StarDDBField, StarDDB

# Create a field and queue operations
field = StarDDBField(0)
field.update("set", 1)
field.update("mult", 5)
field.update("div", 0.5)
field.flush()
print(field.value)  # 10.0

# Use with a database file
db = StarDDB("data.json", save_time=5)
hook = db.db()
hook["health"].update("sub", 30)
hook["mana"].update("mult", 2)
db.close()

API

StarDDBField(value, max_queue_size=10000)

  • value — Initial value (any JSON-serializable type)
  • max_queue_size — Maximum queued operations (default: 10000)

Methods:

  • update(method, value) — Queue an operation. Methods: set, add, sub, mult, div
  • flush() — Block until all queued operations are processed

StarDDB(database, save_time, database_hook=None, safe_root=None)

  • database — Path to the JSON database file
  • save_time — Seconds between automatic saves
  • database_hook — Optional pre-loaded dict (skips file read)
  • safe_root — Optional root directory to restrict path traversal

Methods:

  • db() — Get the database hook (dict of StarDDBField instances)
  • flush() — Block until all field operations are processed
  • close() — Flush, save, and stop the background save thread

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

starddb-1.0.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

starddb-1.0.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file starddb-1.0.0.tar.gz.

File metadata

  • Download URL: starddb-1.0.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for starddb-1.0.0.tar.gz
Algorithm Hash digest
SHA256 626731eeb8d351f33d0cb479bf8c9e8fdcf4838f15ba37e4d18f1a95b1bbee57
MD5 43cd680cbdb6c284affcc64b09887878
BLAKE2b-256 68269858a3cfcd4500d851ca39c077001cbff6046b64f0564e230f90d86cd515

See more details on using hashes here.

File details

Details for the file starddb-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: starddb-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for starddb-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e28e2772cc5bd5d273d82d5a6fe8e9450eeb208aa63ad844355da36e4fd0e042
MD5 0296cd3c390da6c4d47eaed6b42abc64
BLAKE2b-256 5253d58b821904a3dc0c65d0676fc80040f4fce536453beb42c9299880d125ea

See more details on using hashes here.

Supported by

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