{ "info": { "author": "Edwin van Opstal", "author_email": "evo.se-technology.com", "bugtrack_url": null, "classifiers": [], "description": "============================================\ndjango_keyval - a very basic key-value store\n============================================\n\nDjango Keyval is a very basic key-value store that uses Django's database\nbackend. Other than django and the standard python function pickle, there are\nno dependencies. Django Keyval does not rely on a browser, it has no views.\nDjango Keyval provides a simple way to store settings and temporary values in \nyour Django app that are persistent between requests, without having to deal\nwith running an external server such as redis. The drawback, compared to redis,\nis that it is much slower and less flexible.\n\nA typical usage example is::\n\n from django_keyval.models import KeyVal\n\n kv = KeyVal('store_name_1')\n kv.set(key1, value1)\n value2 = kv.get(key2)\n kv.disconnect() # prevents further access\n\n\nWhy yet another key value store?\n================================\n\nTwo reasons:\n\n1. I needed something simple and most of the ones I found were either very\n complex, or had external dependencies that I did not want to worry about.\n\n2. (The real reason) I needed a simple project to learn about packaging, pypi,\n git, virtualenv, etc.\n\nMore Detail\n===========\n\nDjango KeyVal stores *key*-*value* pairs in a *store*, where the *key* and the\n*store* name can be any string. Because Django Keyval uses the standard Python\nPickle function, the *value* can be any python type that can be pickled.\n\nConnecting and disconnecting\n----------------------------\n\nIn order to prevent clashes between different packages/functions using the same\nkey, you first need to connect to a *store name*. Make sure you choose\na unique name. The name can be any Python string.\n\nBefore you can store or retrieve any values, you need to connect to a store::\n\n kv = KeyVal.connect(store_name)\n\nWhich is equivalent to ``kv = KeyVal(store_name)``.\nOnce you are done with this store you can disconnect to prevent further access::\n\n kv.disconnect(store_name)\n\nYou can have multiple stores connected at once.\n**Note:** Any operations on kv after disconnection result in a NameError, except\nfor flush_all()\n\nStoring\n-------\n\nSetting a value for a key is as simple as::\n\n kv.set(key, value)\n\nIf that key already has a value, it is silently overwritten. If you want to\ndetect that, the return value is a boolean that indicates whether the key was\nnew (True) or overwritten (False).\n\nRetrieving\n----------\n\nThere are several ways to get a value of a key:\n\n* Use **get** if you are sure a key exists, it raises an exception if not::\n\n value = kv.get(key)\n\n* Use **get_default** to provide a default value and/or to prevent exceptions::\n\n value = kv.get_default(key, default_value)\n\nIf you want to retrieve a value and then delete it, you can use **pop** or \n**pop_default**, they work identically to get and get_default.\n\n\nChecking if a key exists\n------------------------\n\nIf you just need to know if a key exists, without retrieving the value, the\n``exists`` method can be used. This is just a convenience method, because it is\nno more efficient than retrieving::\n\n if kv.exists(key):\n do_something()\n\nDeleting\n--------\n\nA key-value pair is deleted by using::\n\n kv.delete(key)\n\nIf the key does not exist a KeyError is raised, if you want to ignore errors,\nuse the ``ignore_keyerror`` argument::\n\n deleted = kv.delete(key, ignore_keyerror=True)\n\nIf the key existed, the return value is True, else False.\nFor deleting all key-value pairs in one ``name``, use::\n\n kv.flush()\n\nThis will not raise exceptions if no key-values exist in ``name``\n\nTo delete all key-value pairs in the database, use::\n\n KeyVal.flush_all()\n\nNote that ``kv.flush_all()`` also works, provided ``kv`` is an instance of \nKeyVal.\n\n\nDjango Admin & Command line\n===========================\n\nFor testing and debugging purposes the kv store can be accessed from the \nDjango Admin site. If you have no server running, or you are using Django \nKeyVal stand-alone, you can use the command line to access the database,\nby running the following commands::\n\n $python manage.py keyval -c set -n name -k key -V value\n $python manage.py keyval -c get -n name -k key\n $python manage.py keyval -c del -n name -k key\n\nNote the capital V to avoid conflict with -verbose.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/EdwinvO/django_keyval", "keywords": null, "license": "LICENSE.txt", "maintainer": null, "maintainer_email": null, "name": "django_keyval", "package_url": "https://pypi.org/project/django_keyval/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django_keyval/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/EdwinvO/django_keyval" }, "release_url": "https://pypi.org/project/django_keyval/0.1.2/", "requires_dist": null, "requires_python": null, "summary": "Simple django key-value store", "version": "0.1.2" }, "last_serial": 768733, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "2179ccaa84b0b1617ecda1aa5b8b5b75", "sha256": "4055fd2280a92f27d7321bef27c587dbb54a5f38a2e0a0e99a75af5855773950" }, "downloads": -1, "filename": "django_keyval-0.1.0.tar.gz", "has_sig": false, "md5_digest": "2179ccaa84b0b1617ecda1aa5b8b5b75", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19726, "upload_time": "2013-04-14T23:10:23", "url": "https://files.pythonhosted.org/packages/26/f8/9a79deac9f45de9aeae096cee7940852c607357fada73f7bb7cd61babdfd/django_keyval-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "eee5219ab4f12388c5eee766cd60f40a", "sha256": "a157b8eaca4bf063cca6e78455f7f8bea03faab60f8d1427c33bfdff893edced" }, "downloads": -1, "filename": "django_keyval-0.1.1.tar.gz", "has_sig": false, "md5_digest": "eee5219ab4f12388c5eee766cd60f40a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22654, "upload_time": "2013-04-15T00:10:22", "url": "https://files.pythonhosted.org/packages/26/f2/a99b7f3451a58bf076edc94e4fa424b61274e67a90e5f3ec0113945af152/django_keyval-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "dd4e3528bc50673df69060b741e59f86", "sha256": "9c4ba08c49a1381e98ad9715eab120de448308c9a9723c3b8c6ffa9abd7e8cf6" }, "downloads": -1, "filename": "django_keyval-0.1.2.tar.gz", "has_sig": false, "md5_digest": "dd4e3528bc50673df69060b741e59f86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22755, "upload_time": "2013-04-15T00:26:19", "url": "https://files.pythonhosted.org/packages/a6/95/2ccf19d287a5344d0a853a5acc5d2715e69a9c870a888d4aebe16f67b1b7/django_keyval-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dd4e3528bc50673df69060b741e59f86", "sha256": "9c4ba08c49a1381e98ad9715eab120de448308c9a9723c3b8c6ffa9abd7e8cf6" }, "downloads": -1, "filename": "django_keyval-0.1.2.tar.gz", "has_sig": false, "md5_digest": "dd4e3528bc50673df69060b741e59f86", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22755, "upload_time": "2013-04-15T00:26:19", "url": "https://files.pythonhosted.org/packages/a6/95/2ccf19d287a5344d0a853a5acc5d2715e69a9c870a888d4aebe16f67b1b7/django_keyval-0.1.2.tar.gz" } ] }