A library to handle persistent memory
Project description
membank
Python library for storing data in persistent memory (sqlite, postgresql, berkeley db)
goals
Provide interface to database storage that automates heavy lifting of database setup, migration, table definition, query construction.
quick intro
add items to persistent storage
import dataclasses as data # Python standard library
from membank import LoadMemory
@data.dataclass
class Dog():
breed: str
color: str = "black"
weight: float = 0
memory = LoadMemory() # defaults to sqlite memory
memory.put(Dog('Puli')) # stores object into database
dog = memory.get.dog() # retrieves first object found
assert dog.breed == 'Puli'
retrieve those after
memory = LoadMemory() # to make this work in new process, don't use sqlite memory
dog = memory.get.dog() # get first found or None
assert dog.color == 'black'
dogs = memory.get("dog") # always returns list (empty or with items)
assert len(dogs) >= 0
editing returned objects
dog = memory.get.dog()
dog.breed = 'Labdrador'
memory.put(dog) # stores edited object back
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
membank-0.2.14.tar.gz
(7.3 kB
view details)
Built Distribution
File details
Details for the file membank-0.2.14.tar.gz
.
File metadata
- Download URL: membank-0.2.14.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e4c83fbfbc985575e3a4de47d072e92a0138389115dc34a6727417febe8a7ee |
|
MD5 | 8295823dfd4481f79d0384cc57a3a6d0 |
|
BLAKE2b-256 | 70223704489fa53ed1a0d0ad7b7740c278fa8aaac315c9701f8176bc499bb306 |
File details
Details for the file membank-0.2.14-py3-none-any.whl
.
File metadata
- Download URL: membank-0.2.14-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0f792ee9b567dbf553dbc534f5c16389e8d87edf4387079a737b330d8cc23bf |
|
MD5 | f57f322c5362388719e85d0c499973a0 |
|
BLAKE2b-256 | 0fcbb206cea8fbbd7349ead5a8d03a3b217678feebeee348e3284a3d0e7dc87b |