powerful and lightweight library designed for data and database.
Project description
YamoDB
YamoDB is a powerful and lightweight library designed for data and database manipulation. It enables you to easily create and manage complex databases using YAML files, offering a simple yet efficient way to handle structured data. Whether you're working on small projects or need advanced data management capabilities, YamoDB provides an easy and straightforward approach to store, retrieve, and manipulate data without the need for heavyweight database systems.
🚀 Key Features
📦 Data Management with YAML
- Easily create and manage databases using YAML files.
- Supports complex database structures with relationships, constraints, and data types.
- Ideal for small to medium-sized projects where heavyweight databases are unnecessary.
🔍 Advanced Data Manipulation
- Perform queries like filtering, sorting, and modifying records with ease.
- Includes intuitive methods for data insertion, selection, updates, and deletion.
🔐 Built-in Encryption
- Protect sensitive data with native encryption methods like
encrypt(). - Example:
YamoDB.insert('user', {'password': YamoDB.encrypt('mypassword')}).
⏳ Modern Date and Time Handling
- Effortless date and time manipulation.
- Example:
YamTimes.today().string()to get the current date.
📖 Example Usage
from yamodb import YamoDB, YamTimes
# Setting up YamoDB
YamoDB.secret = "mysecretkey"
YamoDB.delete_old_db = True
YamoDB.connect()
# YAML schema definition
yaml_db = """
user:
name:
type: string
primary_key: true
not_null : true
password:
type: encrypted
not_null: true
money:
type: float
birthdate:
type: date
book:
title:
type: string
primary_key: true
owner:
reference: user.name
on_delete: cascade
"""
# Generate schema and insert data
YamoDB.generate_from(yaml_db)
YamoDB.insert("user", {
'name': 'John Doe',
'password': YamoDB.encrypt('password123'),
'money': YamoDB.number_placeholder(),
'birthdate': YamTimes.today().string()
})
# Select and decrypt user data
YamoDB.select("user").where({'name': 'John Doe'}).decrypt('password').first().print()
# Insert a book associated with the user
YamoDB.insert("book", {'title': 'The Great Gatsby', 'owner': 'John Doe'})
# Retrieve books owned by the user
YamoDB.select("book").where({'owner': 'John Doe'}).print()
# Delete the user and check cascading deletion on books
YamoDB.select("user").where({'name': 'John Doe'}).delete()
YamoDB.select("book").where({'owner': 'John Doe'}).print()
# Close the connection
YamoDB.close()
How This Example Works
- Schema Definition:
yaml_dbdefines the database structure using YAML, including relationships (book.ownerreferencesuser.name). - Data Insertion: Adds a user with encrypted password and placeholder money. Inserts a book linked to the user.
- Queries: Demonstrates querying, decrypting sensitive data, and cascading deletions.
- Cascading Deletion: Deleting a user removes their associated books automatically due to the
on_delete: cascaderule. - Encryption: Passwords are securely encrypted using
YamoDB.encrypt().
YamoDB simplifies database operations while ensuring robust features like encryption and cascading deletions, making it ideal for lightweight applications.
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 yamodb-0.0.1.tar.gz.
File metadata
- Download URL: yamodb-0.0.1.tar.gz
- Upload date:
- Size: 36.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f9d52558570661ba4fd37f8f48a64fff8d98124c796df739c15d233d4cdabf5
|
|
| MD5 |
30cdf76483d0df6e1e74106bd754e7ff
|
|
| BLAKE2b-256 |
c2942cd2b664da584e291cb9f85e57a776bfb9e1edee2fcf671cd2222ea0cfb5
|
File details
Details for the file yamodb-0.0.1-py3-none-any.whl.
File metadata
- Download URL: yamodb-0.0.1-py3-none-any.whl
- Upload date:
- Size: 34.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
747249f968242fd11e7df7701c76a556a647d2a6606acb90e740dd2fe267d57c
|
|
| MD5 |
9deccb89b79557f5dd9b25d9e8440229
|
|
| BLAKE2b-256 |
8dcafc6f5fd3609bc982810e8f07552225b4572f68b41b50c7f3475f31b8f688
|