karpathy / sqlitedict

Persistent dict, backed by sqlite3 and pickle, multithread-safe.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sqlitedict -- persistent dict, backed-up by SQLite and pickle

Travis_ License_

A lightweight wrapper around Python's sqlite3 database with a simple, Pythonic dict-like interface and support for multi-thread access:

Pickle is used internally to (de)serialize the values. Keys are arbitrary strings, values arbitrary pickle-able objects.

If you don't use autocommit (default is no autocommit for performance), then don't forget to call mydict.commit() when done with a transaction:

Features

Installation

The module has no dependencies beyond Python itself. The minimum Python version is 2.5, continuously tested on Python 2.6, 2.7, 3.3 and 3.4 on Travis.

Install or upgrade with:

pip install -U sqlitedict

or from the source tar.gz:

python setup.py install

Documentation

Standard Python document strings are inside the module:

(but it's just dict with a commit, really).

Beware: because of Python semantics, sqlitedict cannot know when a mutable SqliteDict-backed entry was modified in RAM. For example, mydict.setdefault('new_key', []).append(1) will leave mydict['new_key'] equal to empty list, not [1]. You'll need to explicitly assign the mutated object back to SqliteDict to achieve the same effect:

For developers

Install:

# pip install nose
# pip install coverage

To perform all tests:

# make test-all

To perform all tests with coverage:

# make test-all-with-coverage

Comments, bug reports

sqlitedict resides on github. You can file issues or pull requests there.


sqlitedict is open source software released under the Apache 2.0 license. Copyright (c) 2011-now Radim Řehůřek and contributors.

About

Persistent dict, backed by sqlite3 and pickle, multithread-safe.

License:Apache License 2.0


Languages

Language:Python 98.9%Language:Makefile 1.1%