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:
-
Pickle Mode (
mode=False, Default):- Utilizes the standard Python
picklemodule. - 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.
- Utilizes the standard Python
-
Json Mode (
mode=True):- Utilizes the built-in
jsonmodule. - 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).
- Utilizes the built-in
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) andjson(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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file revampdb-1.0.1.1.tar.gz.
File metadata
- Download URL: revampdb-1.0.1.1.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c10dc72aa6d01737578d0fd35fa6e1df537151276c62488338224dc867f0cfe
|
|
| MD5 |
3114ad1defeb0fe7ae423b3d3d2873d2
|
|
| BLAKE2b-256 |
2ad8c8237b2ce641444137019dc34ca645a843e0290f9e8da4607323725ebacc
|
File details
Details for the file revampdb-1.0.1.1-py3-none-any.whl.
File metadata
- Download URL: revampdb-1.0.1.1-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.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ce763270d767e3c59d9a8b00e5df30ba5b5ac6fd863b42a301c2d61c9442107
|
|
| MD5 |
3c4f9a473b77dba0fa79d505dc8d2e00
|
|
| BLAKE2b-256 |
cdbd6f39ff67bfcbcb7bbb3a71db345767016e0673dc766baadf22af50b6ff27
|