A trivial, persistent, dictionary-like object, backed by SQLite.
Project description
# Permadict
[![Build Status](https://travis-ci.org/mivade/permadict.svg?branch=master)](https://travis-ci.org/mivade/permadict)
A trivial, persistent, dictionary-like object, backed by SQLite.
## Installation
` $ python setup.py install `
Or just drop the permadict.py file into your package.
## Usage
Basic usage:
`python >>> from permadict import Permadict >>> d = Permadict("db.sqlite") >>> d["key"] = "value" >>> print(d["key"]) value `
As a context manager:
`python >>> with Permadict("db.sqlite") as d: ... d["something"] = 1.2345 ... >>> with Permadict("db.sqlite") as d: ... print(d["something"]) ... 1.2345 `
Iterating:
`python >>> d = Permadict("db.sqlite") >>> for k, v in d.items(): ... print(k, v) ... something 1.2345 >>> for key in d.keys(): ... print(key) ... something `
Deleting an item:
`python >>> del d["something"] `
Clearing all items:
`python >>> d.clear() `
## Limitations
Keys must be strings. Values are stored as BLOB type after being pickled, so your Python objects must be picklable.
Permadict doesn’t act entirely like a dict: some methods are missing, whether that be on purpose (as with dict.copy) or simply due to negligence.
## Motivation
I needed a way to share small amounts of data between processes. SQLite provides a safe way to do so. Also, why not?
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 Distributions
Built Distribution
Hashes for permadict-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc2cf76fbbc1317e3872b7ec7f25d0b21c698211cf52a949b636697bdbece3e2 |
|
MD5 | 54c7d8e254e55ad2b0273670389c305d |
|
BLAKE2b-256 | 9c953bb0b68d9721f118945bd29491787c44bc89abf6cba766b4edcb4dcc2837 |