A lightweight logging library for Kybra on the Internet Computer (IC)
Project description
Kybra Simple DB
TODO:
fix logging!! test canister update persistance of db data and instantiation test update database with new/less attributes and new/less entities (migrations) why _id needs to be a str? change the logger to an actual Python standard logging... make it possible to select mixings more granually (timestamps / user)
review audit and test examples add coverage linting final cleaning readme remove printouts, TODO, etc. RELEASE!
A lightweight key-value database with entity relationships and audit logging capabilities, intended for small to medium-sized applications running on the Internet Computer using Kybra.
Quick Start
Basic Usage
# Step 1: Import Kybra and define storage
from kybra import StableBTreeMap
db_storage = StableBTreeMap[str, str](memory_id=..., max_key_size=..., max_value_size=...)
# Step 2: Import Kybra Simple DB and initialize database
from kybra_simple_logging import *
Database(db_storage)
# Step 3: Run your application using the database
# TODO
Installation
On your Kybra project, copy the folder
TODO: insert directory tree
If not using Kybra, just:
pip install ...
Features
- Uses IC persistent storage (StableBTreeMap)when used on the Internet Computer, although it can be run outside IC using a custom storage object.
- No need for calling ".save()". Just use the variables seamlessly (TODO: explain better)
- Simple key-value storage with JSON serialization
- Entity-relationship management
- Audit logging of all operations
- Pluggable storage backends
- Type hints for better IDE support
- Zero dependencies
- Python 3.10.7 support
- Timestamp and ownership tracking via mixins
- System time management for testing and synchronization
Advance usage
TODO
Running Tests
To run the test suite:
pip install -r requirements-dev.txt
python -m pytest -v
python -m pylint kybra_simple_logging tests
Development
# Clone the repository
git clone https://github.com/smart-social-contracts/kybra_simple_logging.git
cd kybra_simple_logging
# Recommended steps
pip install pyenv virtualenv
pyenv local 3.10.7
python -m virtualenv venv
source venv/bin/activate
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
cd tests && ./run_test.sh
# Run linters
black .
isort .
flake8 .
mypy .
License
MIT
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 kybra_simple_logging-0.0.1.tar.gz.
File metadata
- Download URL: kybra_simple_logging-0.0.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18329cc71e5f9f6f002d75542fb30b603a7ad7b76ec7f2c7bf5705c66d9d6a88
|
|
| MD5 |
2ff31863ddf28375f799cd811cbb720e
|
|
| BLAKE2b-256 |
18b2986122fb8ba8241baf96f7b24d72c1ef407d5d1b097357aa6f9f299f235b
|
File details
Details for the file kybra_simple_logging-0.0.1-py3-none-any.whl.
File metadata
- Download URL: kybra_simple_logging-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0af27a13b4b11388fe73e24bf243460297b92be606c9fd4c47469d5bba874c2
|
|
| MD5 |
d75840083215545c94258a2cfb115674
|
|
| BLAKE2b-256 |
d7b6159e178e9ea2c02167a2780ec51f83216b48053d111d45fa92d8d10b93d0
|