A SQLAlchemy based Key-Value store.
Project description
KVAlchemy
KVAlchemy is a SQLAlchemy-based key-vault store. It has the ability to get/set values based off a string key, an optional string tag, and an optional expiration time. Additionally it has a built-in ability to memoize function results to the store.
Example
from kvalchemy import KVAlchemy
# Setup. Supports any available sqlalchemy backend.
k = KVAlchemy('sqlite://')
# Set/Get
k.set("hello", "world")
assert k.get("hello") == "world"
# Default values
assert k.get("hello again", "default") == "default"
# memoize example
import time
@k.memoize()
def func():
time.sleep(1)
func() # Will sleep
func() # Won't sleep
func.cache_clear()
func() # Will sleep
# proxy example
proxy = k.get_proxy('pizza')
proxy.set('pie')
assert proxy.get() == 'pie'
proxy.delete()
assert proxy.get('default') == 'default'
Installation
On Python 3.8 or later:
pip install kvalchemy
Versioning
Note that the database format is stable across the same patch version.
For example: Version 0.0.1 will be fully compatible with all releases in the 0.0.X family.
Though Version 0.1.0 may not be directly compatible without a manual data migration.
Make sure to pin the version family you want: kvalachemy<X.(Y+1).0
Testing
KVAlchemy is tested across multiple database backends including MySQL, Postgres, SQLite, and Oracle.
More Documentation
For more documentation visit: https://csm10495.github.io/kvalchemy
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
kvalchemy-0.2.1.tar.gz
(10.7 kB
view hashes)
Built Distribution
Close
Hashes for kvalchemy-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bda9f612606c8b7193bf53d5dfd91db6ae27f8b07df1c446e8118ff1b6fd0f4 |
|
MD5 | 071351fded36d5a2d73315d1fe2030a5 |
|
BLAKE2b-256 | b860d55a9ad4e1f0a57251c313eb75b6b16252e8ed836bd6d191696eef3fe9c5 |