No project description provided
Project description
keyv
A lightweight, file-based NoSQL key-value database designed for simple and practical uses. It requires no external dependencies and stores all data locally in a single file. Perfect for applications needing a straightforward and efficient storage solution.
pip install keyv
How it works
keyv uses sqlite3 as its engine, thereby benefiting from its power, integrity, and practicality. This looks strange but it works like a charm.
Usage
import keyv
# initialize the database
db = keyv.connect('db.keyv') # or .db, or .anything, you choose
# insert a key-value pair
db.put('key1', 'value1')
# by default the .put method is unique safe, i.e. it raises an error
# if the key already exists. if you don't want that behavior you can
# use replace_if_exists=True.
db.put('key1', 'value1', replace_if_exists=True)
# retrieve a value by key
value = db.get('key1')
print(value) # output: 'value1'
# note: the get method returns None for non-existing keys
# update a value
db.update('key1', 123)
updated_value = db.get('key1')
print(updated_value) # output: 123
# delete a key-value pair
db.delete('key1')
# search for keys by value
db.put('key2', 'common_value')
db.put('key3', 'common_value')
keys = db.search('common_value')
print(keys) # output: ['key2', 'key3']
# retrieve all keys
all_keys = db.keys()
print(all_keys) # output: ['key2', 'key3']
keyv uses pickle to serialize data (keys and values). This means you are free to use any python type that can be serialized using pickle for both keys and values.
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
File details
Details for the file keyv-0.1.3.tar.gz
.
File metadata
- Download URL: keyv-0.1.3.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 698164d51a6446f5681a750c9c2f29ca4be6209c29ed74fdce80875b1943d2d8 |
|
MD5 | 50612e9fed24417d9d19718fad64d561 |
|
BLAKE2b-256 | a87f025cb3f9160abe2b5955233dd0b3853f7d8a6ee935c001293c058e1806b3 |
File details
Details for the file keyv-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: keyv-0.1.3-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.1 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 384949d768f0803698ab5278ae1fba4805a16716ba59ac680800eb627cdaef09 |
|
MD5 | 37a196e43bdc7fd97ba1977976bd1cd4 |
|
BLAKE2b-256 | add99fdb62de69365c7a6854889785abddd3a7c2684a47f4071000dda03dcf1a |