database package, simple and lightweight, without encryption, not recommended for use on servers with public access.
Project description
Zeptum
A simple Python-based database library for managing hierarchical data with tables, where each table can have nested keys and values. This project allows you to create tables, input or update data, delete tables, and retrieve data based on a table and key.
Features
- Create Tables: Easily create new tables.
- Insert/Update Data: Input or update values at hierarchical keys.
- Retrieve Data: Retrieve data by table and key.
- Delete Tables: Delete a table and its contents.
- Clear Tables: Clear all data in a table without deleting it.
Installation
There is no installation required if you are using the Python code directly. Simply clone or download the repository and use it in your Python project.
- Clone the repository or install from pypi.
git clone https://github.com/yourusername/simple-database.git
- Install from pypi:
pip3 install zeptum
- Use it in your Python project.
Usage
To use the zeptum, import the ClientBase class and follow the examples below.
Example
# Import the SimpleDatabase class
from zeptum import ClientBase
# Initialize the database
db = SimpleDatabase()
# Create a table
db.create_table("user")
# Insert or update data
db.input("user", "money.balance", 100)
db.input("user", "money.count", 50)
# Retrieve data
balance = db.get_data("user", "money.balance")
print(balance) # Output: 100
# Update existing data
db.update("user", "money.balance", 200)
# Retrieve updated data
updated_balance = db.get_data("user", "money.balance")
print(updated_balance) # Output: 200
# Delete a table
db.delete_table("user")
# Retrieve data after table deletion
deleted_balance = db.get_data("user", "money.balance")
print(deleted_balance) # Output: None
Methods
-
create_table(table_name: str):- Creates a new table in the database if it doesn’t already exist.
-
input(table_name: str, key: str, value: Union[str, int, float, Dict]):- Inserts or updates the value at the specified key in the given table.
- Example key format:
"money.balance","user.name".
-
get_data(table_name: str, key: str) -> Optional[Union[str, int, float, Dict]]:- Retrieves the value at the specified key in the table.
- Returns
Noneif the table or key does not exist.
-
update(table_name: str, key: str, value: Union[str, int, float, Dict]) -> bool:- Updates an existing value in the specified table and key.
- Returns
Trueif the update was successful,Falseif the key doesn’t exist.
-
delete_table(table_name: str) -> bool:- Deletes the entire table from the database.
- Returns
Trueif the table was deleted,Falseif the table does not exist.
-
clear_table(table_name: str) -> bool:- Clears all data in the specified table without deleting the table itself.
- Returns
Trueif the table was cleared,Falseif the table does not exist.
-
show():- Returns the entire database as a dictionary.
-
Donwloads from pypi:
pip3 install zeptum
- Run the code:
python3 main_db.py
License
This project is open-source and available under the MIT License.
Contributing
If you'd like to contribute to the development of this library, feel free to fork the repository and submit a pull request. Contributions are welcome!
Project details
Release history Release notifications | RSS feed
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 zeptum-1.0.1.tar.gz.
File metadata
- Download URL: zeptum-1.0.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0970c959fabee639a85a793805744e2cd56cc54572d9d948a252e5634b789160
|
|
| MD5 |
53867a59205abd84397d91ba7b1715f1
|
|
| BLAKE2b-256 |
7da286b29b00c1a81527c1ed4e9a4d9f5f063f0a904ec900c2313376a0485e8a
|
File details
Details for the file zeptum-1.0.1-py3-none-any.whl.
File metadata
- Download URL: zeptum-1.0.1-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bbd6573231f908eda55d9b0d83b859009252a709d4fd1d2bc98a2fdc5c251d3
|
|
| MD5 |
a5bf545cd3938217b9754fc4baab4ba9
|
|
| BLAKE2b-256 |
92baf33f9c90ca8d2ebcd38db2240c82ab0f44713980278e35545f6a8c1c4ec5
|