Skip to main content

A lightweight key-value database written in Python, intended for use with 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!

Test PyPI version Python Versions Coverage License

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

Example 1

# 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_db 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

Example 2

TODO

Running Tests

To run the test suite:

pip install -r requirements-dev.txt
python -m pytest -v
python -m pylint kybra_simple_db tests

Development

# Clone the repository
git clone https://github.com/smart-social-contracts/kybra_simple_db.git
cd kybra_simple_db

# 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

kybra_simple_db-0.1.2.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

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

kybra_simple_db-0.1.2-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file kybra_simple_db-0.1.2.tar.gz.

File metadata

  • Download URL: kybra_simple_db-0.1.2.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for kybra_simple_db-0.1.2.tar.gz
Algorithm Hash digest
SHA256 12142590967342fe50fc4898eea66ee70aec36fed8e1ba1c4251945be97ddedf
MD5 9ccaed9712ac58f88c8a73260b1e749c
BLAKE2b-256 fc394d3de9ff1da3352adf179da298ff6fad44ba2a41e940f7581d84043c96f5

See more details on using hashes here.

File details

Details for the file kybra_simple_db-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for kybra_simple_db-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3eac13cbb40299c8f304b1c7ba7b652aff50c5109e567714c4e8c977955466d5
MD5 5443d3d353ea9eecf616d61ee4f6a738
BLAKE2b-256 625366cc0e522ea0860727f8d12696b461c6c7fb5354f3983a072eedbe967f34

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