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:

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.1.tar.gz (17.5 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.1-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kybra_simple_db-0.1.1.tar.gz
  • Upload date:
  • Size: 17.5 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.1.tar.gz
Algorithm Hash digest
SHA256 c43b8bdc0e28ca6383d015d951a870dd57fee6d8567d07b5ae94dc3cccc7c24c
MD5 13ead98465614460e370f8e078e66994
BLAKE2b-256 eae85e4ba21b8a227494b436bd0e29e26ee11c5d87903f3c484dcca316dc4368

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for kybra_simple_db-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a8404bb5c0f73384968d8757762ebfb40aa9ce594bfebd18c895dbb4797db3de
MD5 8a617a2a5fc4118cc1146306f6f72a33
BLAKE2b-256 919cbd0e40d6ea3b30bbe3caacce56a5fb24fd81e85b0f1057fa990b2276cd7b

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