add sqlitedict

This commit is contained in:
j 2016-02-11 16:18:40 +05:30
commit 6ab699c9c8
9 changed files with 779 additions and 0 deletions

View file

@ -0,0 +1,135 @@
=================================================================
sqlitedict -- persistent ``dict``, backed-up by SQLite and pickle
=================================================================
|Travis|_
|Downloads|_
|License|_
.. |Travis| image:: https://img.shields.io/travis/piskvorky/sqlitedict.svg
.. |Downloads| image:: https://img.shields.io/pypi/dm/sqlitedict.svg
.. |License| image:: https://img.shields.io/pypi/l/sqlitedict.svg
.. _Travis: https://travis-ci.org/piskvorky/sqlitedict
.. _Downloads: https://pypi.python.org/pypi/sqlitedict
.. _License: https://pypi.python.org/pypi/sqlitedict
A lightweight wrapper around Python's sqlite3 database with a simple, Pythonic
dict-like interface and support for multi-thread access:
.. code-block:: python
>>> from sqlitedict import SqliteDict
>>> mydict = SqliteDict('./my_db.sqlite', autocommit=True)
>>> mydict['some_key'] = any_picklable_object
>>> print mydict['some_key'] # prints the new value
>>> for key, value in mydict.iteritems():
>>> print key, value
>>> print len(mydict) # etc... all dict functions work
>>> mydict.close()
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:
.. code-block:: python
>>> # using SqliteDict as context manager works too (RECOMMENDED)
>>> with SqliteDict('./my_db.sqlite') as mydict: # note no autocommit=True
... mydict['some_key'] = u"first value"
... mydict['another_key'] = range(10)
... mydict.commit()
... mydict['some_key'] = u"new value"
... # no explicit commit here
>>> with SqliteDict('./my_db.sqlite') as mydict: # re-open the same DB
... print mydict['some_key'] # outputs 'first value', not 'new value'
Features
--------
* Values can be **any picklable objects** (uses ``cPickle`` with the highest protocol).
* Support for **multiple tables** (=dicts) living in the same database file.
* Support for **access from multiple threads** to the same connection (needed by e.g. Pyro).
Vanilla sqlite3 gives you ``ProgrammingError: SQLite objects created in a thread can
only be used in that same thread.``
Concurrent requests are still serialized internally, so this "multithreaded support"
**doesn't** give you any performance benefits. It is a work-around for sqlite limitations in Python.
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 <https://travis-ci.org/piskvorky/sqlitedict>`_.
Install or upgrade with::
easy_install -U sqlitedict
or from the `source tar.gz <http://pypi.python.org/pypi/sqlitedict>`_::
python setup.py install
Documentation
-------------
Standard Python document strings are inside the module:
.. code-block:: python
>>> import sqlitedict
>>> help(sqlitedict)
(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:
.. code-block:: python
>>> val = mydict.get('new_key', [])
>>> val.append(1) # sqlite DB not updated here!
>>> mydict['new_key'] = val # now updated
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 <https://github.com/piskvorky/sqlitedict>`_. You can file
issues or pull requests there.
History
-------
**1.4.0**: fix regression where iterating over keys/values/items returned a full list instead of iterator
**1.3.0**: improve error handling in multithreading (`PR #28 <https://github.com/piskvorky/sqlitedict/pull/28>`_); 100% test coverage.
**1.2.0**: full python 3 support, continuous testing via `Travis CI <https://travis-ci.org/piskvorky/sqlitedict>`_.
----
``sqlitedict`` is open source software released under the `Apache 2.0 license <http://opensource.org/licenses/apache2.0.php>`_.
Copyright (c) 2011-now `Radim Řehůřek <http://radimrehurek.com>`_ and contributors.

View file

@ -0,0 +1,158 @@
Metadata-Version: 2.0
Name: sqlitedict
Version: 1.4.0
Summary: Persistent dict in Python, backed up by sqlite3 and pickle, multithread-safe.
Home-page: https://github.com/piskvorky/sqlitedict
Author: Radim Rehurek
Author-email: me@radimrehurek.com
License: Apache 2.0
Download-URL: http://pypi.python.org/pypi/sqlitedict
Keywords: sqlite,persistent dict,multithreaded
Platform: any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Topic :: Database :: Front-Ends
=================================================================
sqlitedict -- persistent ``dict``, backed-up by SQLite and pickle
=================================================================
|Travis|_
|Downloads|_
|License|_
.. |Travis| image:: https://img.shields.io/travis/piskvorky/sqlitedict.svg
.. |Downloads| image:: https://img.shields.io/pypi/dm/sqlitedict.svg
.. |License| image:: https://img.shields.io/pypi/l/sqlitedict.svg
.. _Travis: https://travis-ci.org/piskvorky/sqlitedict
.. _Downloads: https://pypi.python.org/pypi/sqlitedict
.. _License: https://pypi.python.org/pypi/sqlitedict
A lightweight wrapper around Python's sqlite3 database with a simple, Pythonic
dict-like interface and support for multi-thread access:
.. code-block:: python
>>> from sqlitedict import SqliteDict
>>> mydict = SqliteDict('./my_db.sqlite', autocommit=True)
>>> mydict['some_key'] = any_picklable_object
>>> print mydict['some_key'] # prints the new value
>>> for key, value in mydict.iteritems():
>>> print key, value
>>> print len(mydict) # etc... all dict functions work
>>> mydict.close()
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:
.. code-block:: python
>>> # using SqliteDict as context manager works too (RECOMMENDED)
>>> with SqliteDict('./my_db.sqlite') as mydict: # note no autocommit=True
... mydict['some_key'] = u"first value"
... mydict['another_key'] = range(10)
... mydict.commit()
... mydict['some_key'] = u"new value"
... # no explicit commit here
>>> with SqliteDict('./my_db.sqlite') as mydict: # re-open the same DB
... print mydict['some_key'] # outputs 'first value', not 'new value'
Features
--------
* Values can be **any picklable objects** (uses ``cPickle`` with the highest protocol).
* Support for **multiple tables** (=dicts) living in the same database file.
* Support for **access from multiple threads** to the same connection (needed by e.g. Pyro).
Vanilla sqlite3 gives you ``ProgrammingError: SQLite objects created in a thread can
only be used in that same thread.``
Concurrent requests are still serialized internally, so this "multithreaded support"
**doesn't** give you any performance benefits. It is a work-around for sqlite limitations in Python.
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 <https://travis-ci.org/piskvorky/sqlitedict>`_.
Install or upgrade with::
easy_install -U sqlitedict
or from the `source tar.gz <http://pypi.python.org/pypi/sqlitedict>`_::
python setup.py install
Documentation
-------------
Standard Python document strings are inside the module:
.. code-block:: python
>>> import sqlitedict
>>> help(sqlitedict)
(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:
.. code-block:: python
>>> val = mydict.get('new_key', [])
>>> val.append(1) # sqlite DB not updated here!
>>> mydict['new_key'] = val # now updated
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 <https://github.com/piskvorky/sqlitedict>`_. You can file
issues or pull requests there.
History
-------
**1.4.0**: fix regression where iterating over keys/values/items returned a full list instead of iterator
**1.3.0**: improve error handling in multithreading (`PR #28 <https://github.com/piskvorky/sqlitedict/pull/28>`_); 100% test coverage.
**1.2.0**: full python 3 support, continuous testing via `Travis CI <https://travis-ci.org/piskvorky/sqlitedict>`_.
----
``sqlitedict`` is open source software released under the `Apache 2.0 license <http://opensource.org/licenses/apache2.0.php>`_.
Copyright (c) 2011-now `Radim Řehůřek <http://radimrehurek.com>`_ and contributors.

View file

@ -0,0 +1,10 @@
sqlitedict.py,sha256=9zIUg7xFsnHFXc07KklfLKKvtcF6Ph6VjHI7biEii98,17577
sqlitedict-1.4.0.dist-info/DESCRIPTION.rst,sha256=0DtdGW_JnxlMrNq3w5Z8X89LZR2GEmNUpc3bqUN-elY,4592
sqlitedict-1.4.0.dist-info/METADATA,sha256=U_yEc91oeI2LREBIsyZv9scFcKu4IF8XBxrBaRAjX_Y,5514
sqlitedict-1.4.0.dist-info/RECORD,,
sqlitedict-1.4.0.dist-info/WHEEL,sha256=AXucK5-TNISW1dQAdsyH02xCRCCE1VKjhXIOWMW_lxI,93
sqlitedict-1.4.0.dist-info/metadata.json,sha256=Gu_BazsbomIjBcE4XjoiZV6U7DUJpWklZudlIYduauI,1070
sqlitedict-1.4.0.dist-info/pbr.json,sha256=wraF_0ld56r3l9udmVdBYB-N7W8nh7Ax8-HRVqiGRFE,46
sqlitedict-1.4.0.dist-info/top_level.txt,sha256=gRsHHG_lHd0G92cPsIV8dhQS7yZfJUYW5GY_oqapYik,11
/tmp/p3k/lib/python3.5/site-packages/sqlitedict-1.4.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
__pycache__/sqlitedict.cpython-35.pyc,,

View file

@ -0,0 +1,5 @@
Wheel-Version: 1.0
Generator: bdist_wheel (0.29.0)
Root-Is-Purelib: true
Tag: cp35-none-any

View file

@ -0,0 +1 @@
{"classifiers": ["Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Topic :: Database :: Front-Ends"], "download_url": "http://pypi.python.org/pypi/sqlitedict", "extensions": {"python.details": {"contacts": [{"email": "me@radimrehurek.com", "name": "Radim Rehurek", "role": "author"}], "document_names": {"description": "DESCRIPTION.rst"}, "project_urls": {"Home": "https://github.com/piskvorky/sqlitedict"}}}, "generator": "bdist_wheel (0.29.0)", "keywords": ["sqlite", "persistent", "dict", "multithreaded"], "license": "Apache 2.0", "metadata_version": "2.0", "name": "sqlitedict", "platform": "any", "summary": "Persistent dict in Python, backed up by sqlite3 and pickle, multithread-safe.", "version": "1.4.0"}

View file

@ -0,0 +1 @@
{"is_release": true, "git_version": "9351e48"}

View file

@ -0,0 +1 @@
sqlitedict