Skip to main content

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.

  1. Clone the repository or install from pypi.
    git clone https://github.com/yourusername/simple-database.git
    
  2. Install from pypi:
    pip3 install zeptum
    
  3. 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

  1. create_table(table_name: str):

    • Creates a new table in the database if it doesn’t already exist.
  2. 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".
  3. get_data(table_name: str, key: str) -> Optional[Union[str, int, float, Dict]]:

    • Retrieves the value at the specified key in the table.
    • Returns None if the table or key does not exist.
  4. update(table_name: str, key: str, value: Union[str, int, float, Dict]) -> bool:

    • Updates an existing value in the specified table and key.
    • Returns True if the update was successful, False if the key doesn’t exist.
  5. delete_table(table_name: str) -> bool:

    • Deletes the entire table from the database.
    • Returns True if the table was deleted, False if the table does not exist.
  6. clear_table(table_name: str) -> bool:

    • Clears all data in the specified table without deleting the table itself.
    • Returns True if the table was cleared, False if the table does not exist.
  7. show():

    • Returns the entire database as a dictionary.
  8. Donwloads from pypi:

pip3 install zeptum
  1. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zeptum-1.0.1.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

zeptum-1.0.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for zeptum-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0970c959fabee639a85a793805744e2cd56cc54572d9d948a252e5634b789160
MD5 53867a59205abd84397d91ba7b1715f1
BLAKE2b-256 7da286b29b00c1a81527c1ed4e9a4d9f5f063f0a904ec900c2313376a0485e8a

See more details on using hashes here.

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

Hashes for zeptum-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8bbd6573231f908eda55d9b0d83b859009252a709d4fd1d2bc98a2fdc5c251d3
MD5 a5bf545cd3938217b9754fc4baab4ba9
BLAKE2b-256 92baf33f9c90ca8d2ebcd38db2240c82ab0f44713980278e35545f6a8c1c4ec5

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