Skip to main content

An Easiest Atomic Database

Project description

RevampDB: Easiest Atomic Database

RevampDB is a minimalist and robust Python utility class designed for simple, persistent key-value storage. It enables developers to quickly save and retrieve data to a local file, serving as an ideal lightweight database replacement for small-scale applications, configuration management, or caching layers.

Core Modes & Serialization

The class offers two distinct operational modes for handling data serialization:

  1. Pickle Mode (mode=False, Default):

    • Utilizes the standard Python pickle module.
    • Provides efficient serialization of complex Python objects (e.g., custom classes, complex nested structures).
    • Files are non-human-readable and are best for internal application use.
  2. Json Mode (mode=True):

    • Utilizes the built-in json module.
    • Ensures data is human-readable, easily shareable, and portable across different systems or languages.
    • Requires data to be composed of standard JSON-compatible types (lists, dictionaries, strings, numbers, boolean, null).

Key Features

  • Simple API: Offers intuitive methods (WriteDatabase, ReadDatabase, etc.) for managing data and the underlying file.
  • Dual Format Support: Seamlessly handles both pickle (binary) and json (text) formats based on the initialization mode.
  • Atomic Write Operation: Guarantees data integrity by utilizing a temporary file during the write process. After the data has been fully and successfully written, preventing file corruption upon interruption.
  • Optional Logging: Provides clear console output to track successful write and delete operations when enabled (logging=True).

Installation & Usage

Installation

If packaged on PyPI, installation is standard:

pip install revampDB

(Note: As a single-file class, you may also integrate the source file directly into your project.)

Usage Example

from revampDB import database # Assuming the class is named 'database' in your module

# 1. JSON Mode (mode=True)
db_config = database("config.json", mode=True, logging=True)
db_config.WriteDatabase({"username": "alice", "email": "a@example.com"}, cell="user_profile")

# Retrieve and print specific data
profile = db_config.ReadDatabase("user_profile")
print(f"User Profile: {profile}") 
# Output: User Profile: {'username': 'alice', 'email': 'a@example.com'}

# 2. Pickle Mode (mode=False) - suitable for complex objects
db_cache = database("data.dat", mode=False)
db_cache.WriteDatabase([1, 2, 3, {'a': 1}], cell="data_list")

# Read entire database contents
all_data = db_cache.ReadEntireDatabase()
print(f"All Data: {all_data}")
# Output: All Data: {'data_list': [1, 2, 3, {'a': 1}]}

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

revampdb-1.0.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

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

revampdb-1.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file revampdb-1.0.1.tar.gz.

File metadata

  • Download URL: revampdb-1.0.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for revampdb-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6563d8750f3287dfdf2ebfd0a55f94f322ce9041e78c75ceed2d80051b3cf7dd
MD5 8befe9215beb5963f9957c84695c7b7f
BLAKE2b-256 9f6e7c02d320e17cbc61a41fb6da574b553fde94b99660adc0c257d1bfbb1a9a

See more details on using hashes here.

File details

Details for the file revampdb-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: revampdb-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for revampdb-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f0e07c82bde55ba79bf59a18aca666b8cede195be3dbadd63ca63a5acf40cff0
MD5 b566b339a987b8b87032ed78113cb970
BLAKE2b-256 77b5b7f10911eeeaf986f292b1f6ddd70ded6d16b9a368307cdd45e3f2538425

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