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.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-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: revampdb-1.0.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.tar.gz
Algorithm Hash digest
SHA256 ad5737d1208fcb826817e8ed962cc3d50401c79dfb6be7bc37c2ae2cb6934359
MD5 cac4ee7b62f443521c538435b58a9737
BLAKE2b-256 2ec6d723813b1c7f4730c9bb002f00a07d7aeee1b376ed018cd5234d42619fa1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: revampdb-1.0-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-py3-none-any.whl
Algorithm Hash digest
SHA256 9aec06b43d7bdc2bfae352d23dc0f7a83cb47cef8c13ed550cb6a89147d455e1
MD5 9988b0c24f973be792e21ce9fc5cc1b1
BLAKE2b-256 3a613574510d2be9f287d99ff1ff2ab15ef97a4e13e06ddb55ef7bb6fa86081b

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