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.

Static Badge

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for revampdb-1.0.2.tar.gz
Algorithm Hash digest
SHA256 812ebd768869fc2da6e29f2fb0c372ecff4db0e4be8328e610f8307bb341032c
MD5 76bdc9a91da6d7646dda6c997ae65236
BLAKE2b-256 42e6a2125dca2f4735088c6cf76f1a356ccc77e98a13890d6fc99d17e5b486b5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for revampdb-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bf43d84fd57b2ebac5388d9610636ea4e0fd0c4026841d2ba306e97e46b0f7f7
MD5 f10b287168f7cf903b9f4145cabc1d22
BLAKE2b-256 a81236dec03812635492cd875cd75ba9e8250530eca844ec4a22d8d5e2774969

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