Open Source Reactive Database
Project description
Skypy - Open Source Reactive Database.
The better way to build Python logging system!
pip install skypydb # python client
# or download from the source
# git clone https://github.com/Ahen-Studio/skypy-db.git
# cd skypy-db
# pip install -r requirements.txt
Features
-
Simple: fully-documented
-
Table: create, delete, search data from tables
-
Security, Input Validation: AES-256-GCM encryption for data at rest with selective field encryption, automatic protection against SQL injection attacks
-
CLI: command line interface to initialize your database and launch the dashboard with one simple command
-
Observable: Dashboard with real-time data, metrics, and query inspection
-
Free & Open Source: MIT Licensed
TODO
- Create the dashboard using Reflex
- update the documentation
What's next!
- give us ideas!
Cli
- use the cli to initialize your database and launch the dashboard with one simple command
skypydb dev
- run this command in your terminal
API
- Use the API to interact with your database; before doing so, make sure to create a schema to define your tables.
"""
Schema definition for Skypydb database tables.
This file defines all tables, their columns, types, and indexes.
"""
from skypydb.schema import defineSchema, defineTable
from skypydb.schema.values import v
# Define the schema with all tables
schema = defineSchema({
# Table pour les logs de succès
"success": defineTable({
"component": v.string(),
"action": v.string(),
"message": v.string(),
"details": v.optional(v.string()),
"user_id": v.optional(v.string()),
})
.index("by_component", ["component"])
.index("by_action", ["action"])
.index("by_user", ["user_id"])
.index("by_component_and_action", ["component", "action"]),
# Table pour les logs d'avertissement
"warning": defineTable({
"component": v.string(),
"action": v.string(),
"message": v.string(),
"details": v.optional(v.string()),
"user_id": v.optional(v.string()),
})
.index("by_component", ["component"])
.index("by_action", ["action"])
.index("by_user", ["user_id"])
.index("by_component_and_action", ["component", "action"]),
# Table pour les logs d'erreur
"error": defineTable({
"component": v.string(),
"action": v.string(),
"message": v.string(),
"details": v.optional(v.string()),
"user_id": v.optional(v.string()),
})
.index("by_component", ["component"])
.index("by_action", ["action"])
.index("by_user", ["user_id"])
.index("by_component_and_action", ["component", "action"]),
})
- after creating the schema file containing the tables, you can add data to your database
import skypydb
# Create a client
client = skypydb.Client(path="./skypydb/skypydb.db")
# Create tables from the schema
# This reads the schema from skypydb/schema.py and creates all tables
tables = client.create_table()
# Access your tables
success_table = tables["success"]
warning_table = tables["warning"]
error_table = tables["error"]
# Insert data
# Insert success logs
success_table.add(
component="AuthService",
action="login",
message="User logged in successfully",
user_id="user123"
)
# Insert warning logs
warning_table.add(
component="AuthService",
action="login_attempt",
message="Multiple failed login attempts",
user_id="user456",
details="5 failed attempts in 5 minutes"
)
# Insert error logs
error_table.add(
component="DatabaseService",
action="connection",
message="Connection timeout",
user_id="system",
details="Timeout after 30 seconds"
)
- after adding data to your database you can search specific data using the search method
user_success_logs = success_table.search(
index="by_user",
user_id="user123"
)
for user_success_log in user_success_logs:
print(user_success_log)
- you can also delete specific data from your database using the delete method
success_table.delete(
component="AuthService",
user_id="user123"
)
Secure Implementation
- first create an encryption key and a salt key and make them available in the .env.local file don't show those keys to anyone, you can use the Cli to generate those keys
# you can generate a secure encryption key and salt using the cli
# or generate a secure encryption key and salt using the this example code
from skypydb.security import EncryptionManager
# Generate a secure encryption key
encryption_key = EncryptionManager.generate_key()
salt = EncryptionManager.generate_salt()
print(encryption_key) # don't show this key to anyone
print(salt) # don't show this salt to anyone
- Use the encryption key to encrypt sensitive data
import os
import skypydb
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
# Load encryption key from environment
encryption_key = os.getenv("ENCRYPTION_KEY") # create a encryption key and make it available in .env file before using it, don't show this key to anyone
salt_key = os.getenv("SALT_KEY") # create a salt key and make it available in .env file before using it, don't show this salt to anyone
# transform salt key to bytes
if salt_key is None:
raise ValueError("SALT_KEY missing")
salt_bytes = salt_key.encode("utf-8")
# Create encrypted database
client = skypydb.Client(
path="./skypydb/skypydb.db",
encryption_key=encryption_key,
salt=salt_bytes,
encrypted_fields=["message"] # Optional: encrypt only sensitive fields
)
# All operations work the same - encryption is transparent!
tables = client.create_table()
# Access your tables
success_table = tables["success"]
warning_table = tables["warning"]
error_table = tables["error"]
# Automatically encrypted
success_table.add(
component="AuthService",
action="login",
message="User logged in successfully", # only this field is encrypted if encrypted_fields is not None
user_id="user123"
)
# Data is automatically decrypted when retrieved
user_success_logs = success_table.search(
index="by_user",
user_id="user123"
)
for user_success_log in user_success_logs:
print(user_success_log)
Learn more on our Docs
License
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 skypydb-0.1.7.tar.gz.
File metadata
- Download URL: skypydb-0.1.7.tar.gz
- Upload date:
- Size: 26.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2db857f320d8b4bb7aaac5cc65ac2bd60289cc445596f97f5099c4182fe10685
|
|
| MD5 |
548ce201c6c72cc567a84382b8463a0c
|
|
| BLAKE2b-256 |
4fb46dbe7bdfbdac7e0bd69ce531cc8085cbf562cd5563e00c6fa13457514b1b
|
Provenance
The following attestation bundles were made for skypydb-0.1.7.tar.gz:
Publisher:
python-publish.yml on Ahen-Studio/skypy-db
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
skypydb-0.1.7.tar.gz -
Subject digest:
2db857f320d8b4bb7aaac5cc65ac2bd60289cc445596f97f5099c4182fe10685 - Sigstore transparency entry: 854573842
- Sigstore integration time:
-
Permalink:
Ahen-Studio/skypy-db@0896a67a50e7037ad190d0e60fa33a6cc59aa460 -
Branch / Tag:
refs/tags/0.1.7 - Owner: https://github.com/Ahen-Studio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0896a67a50e7037ad190d0e60fa33a6cc59aa460 -
Trigger Event:
release
-
Statement type:
File details
Details for the file skypydb-0.1.7-py3-none-any.whl.
File metadata
- Download URL: skypydb-0.1.7-py3-none-any.whl
- Upload date:
- Size: 29.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b95b5522b20cee84e53e752b07c2f7ba3564ac5847cfa39bc40bcc493cac569
|
|
| MD5 |
06ce630f11d3cc239ab827604c4d8121
|
|
| BLAKE2b-256 |
0c34693928f81881852fe8fca9094e745f79a45afb00d9ef49e1f60ea3ba23f1
|
Provenance
The following attestation bundles were made for skypydb-0.1.7-py3-none-any.whl:
Publisher:
python-publish.yml on Ahen-Studio/skypy-db
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
skypydb-0.1.7-py3-none-any.whl -
Subject digest:
1b95b5522b20cee84e53e752b07c2f7ba3564ac5847cfa39bc40bcc493cac569 - Sigstore transparency entry: 854573846
- Sigstore integration time:
-
Permalink:
Ahen-Studio/skypy-db@0896a67a50e7037ad190d0e60fa33a6cc59aa460 -
Branch / Tag:
refs/tags/0.1.7 - Owner: https://github.com/Ahen-Studio
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0896a67a50e7037ad190d0e60fa33a6cc59aa460 -
Trigger Event:
release
-
Statement type: