{ "info": { "author": "Jeremy Kelley", "author_email": "jeremy@33ad.org", "bugtrack_url": null, "classifiers": [], "description": ".. image:: https://github.com/nod/databag/raw/master/dbag.png\n :align: right\n :alt: d bag\n\nPUT YOUR DATA IN A BAG\n========================\n\nPretty simple library for just splatting stuff to disk and getting it back out\nwith minimal fuss.\n\nwait...\n-------\n\nThis is sort of like a nosql db on top of an sql db, right?\n\nYep.\n\nfeatures\n========\n\n* Easy to use and quite efficient at accessing relatively large number of items\n (not talking big data here, but a couple of thousand items works well)\n* Requires no other libs, everything is python batteries included.\n* Built on top of sqlite3 so it's fast and stable (which is included in Python\n stdlib)\n* Easy to use - just create one and use it like a dictionary. Most dict methods\n supported. Also can add to it like a set by not specifying a key. One will\n be created on the fly.\n* Mostly well tested\n* Ideal for running on small vm instances. Doesn't require any other daemon to\n provide data access\n* Core code is about 400 lines - very easy to understand.\n* Automatically compresses data with bz2 in cases that benefit from it\n* You can always query the data with native sqlite3 libs from other languages\n if you need to. It's just strings in the database.\n* Since the underlying datafile is sqlite3, multiple processes can work with\n the same file (multiple read, write locks, etc)\n* Every object gets a ts object attached to it for convenience when it's saved.\n This is accessed via `bag.when('key')`\n\nversioning\n----------\n\nSimple versioning is possible. Just create your DataBag like:::\n\n >>> dbag = DataBag(versioned=True)\n\nand then you can do things like...::\n\n >>> dbag['blah'] = 'blip'\n >>> dbag['blah'] = 'new blip'\n >>> dbag['blah'] = 'newer blip'\n >>> dbag.get('blah', version=-2)\n u'blip'\n >>> dbag.get('blah', version=-1)\n u'new blip'\n >>> dbag.get('blah')\n u'newer blip'\n >>> dbag['blah']\n u'newer blip'\n\nThe default is to keep 10 versions but that can be set with the `history`\nparameter when initializing your bag.\n\nA bag.get(...) method works much like a dictionary's `.get(...)` but with an\nadditional keyword argument of `version` that indicates how far back to go.\n\nexamples\n========\n\n::\n\n >>> from databag import DataBag\n >>> bag = DataBag() # will store sqlite db in memory\n >>> bag['xyz'] = 'some string' # will save in the db\n >>> s = bag['xyz'] # retrieves from db\n >>> s\n 'some string'\n >>> 'xyz' in bag # True\n True\n >>> bag['abc'] = {'x':22, 'y':{'a':'blah'}} # works\n >>> bag['abc']\n {u'y': {u'a': u'blah'}, u'x': 22}\n >>> [k for k in bag]\n ['abc', 'xyz']\n >>> bag.when('xyz')\n datetime.datetime(2011, 12, 31, 2, 45, 47, 187621)\n >>> del bag['xyz']\n >>> 'xyz' in bag\n False\n >>> meh = DataBag(bag='other') # set name of storage table\n\nDictBag example\n---------------\n\n::\n\n >>> from databag import DictBag, Q\n >>> d = DictBag()\n >>> d.ensure_index(('name', 'age'))\n >>> person1 = {'name':'joe', 'age':23}\n >>> person2 = {'name':'sue', 'age':44}\n >>> d.add(person1)\n 'fachVqv6RxsmCXAZgJMJ5p'\n >>> d.add(person2)\n 'fpC7cAtx2ZQLadprQR7aa6'\n >>> d.find(Q('age')>40).next()\n (u'fpC7cAtx2ZQLadprQR7aa6', {u'age': 44, u'name': u'sue'})\n >>> age = Q('age')\n >>> [p for p in d.find(20 < age < 50) ]\n [(u'fachVqv6RxsmCXAZgJMJ5p', {u'age': 23, u'name': u'joe'}),\n (u'fpC7cAtx2ZQLadprQR7aa6', {u'age': 44, u'name': u'sue'})]\n >>>\n\nlimitations\n-----------\n\n* although a lot of the basic data types in python are supported for the values\n (lists, dictionaries, tuples, ints, strings)... datetime objects can be saved\n fine but they come out of the bag as an iso format string of the original\n datetime.\n* when saving a dictionary, the keys must be a string in the dictionary. If\n they are not, they will be when coming back from the bag\n* if using versioning, be sure to instantiate your DataBag object with\n versioning enabled and the same `history` size each time. Failure to do so\n will cause interesting things to happen, in particular, your databag will act\n unversioned and overwrite recent updates w/o cascading the historical change\n to records.\n\n\nFurther notes\n-------------\n\nThe `DictShield library`_ makes an excellent compliment to creation of models\nthat map and store quite nicely in DictBags. A contrib class is included in\ndatabag that inherits from dictshield.document.Document and adds some helpers\nfor storing/retrieving DictShield models from DictBags.\n\n.. _DictShield library : https://github.com/j2labs/dictshield", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/nod/databag", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "databag", "package_url": "https://pypi.org/project/databag/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/databag/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/nod/databag" }, "release_url": "https://pypi.org/project/databag/0.3.2-mod/", "requires_dist": null, "requires_python": null, "summary": "Put your data in a bag and get it back out again", "version": "0.3.2-mod" }, "last_serial": 788785, "releases": { "0.2-15-gc6cc-mod": [], "0.2-30-g69f6-mod": [ { "comment_text": "", "digests": { "md5": "b03ae3cc8460ff5e0c97ef2c88a37736", "sha256": "fe2633670cb98a867208c935ca601240e553a9911293f27c81c23a42bcbc4fb1" }, "downloads": -1, "filename": "databag-0.2-30-g69f6-mod.tar.gz", "has_sig": false, "md5_digest": "b03ae3cc8460ff5e0c97ef2c88a37736", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5394, "upload_time": "2012-08-09T08:38:29", "url": "https://files.pythonhosted.org/packages/97/50/72e2b58ac4fae6b6fee72c33729263b1eeff721aa231089c6f223c8078b8/databag-0.2-30-g69f6-mod.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "4f417ce902a2a07bfa22eca24c94c54f", "sha256": "68071be5a61213656ae9fa96fa18d6c2335bbf5ead13e618cb92f3c7f4860eaf" }, "downloads": -1, "filename": "databag-0.3.tar.gz", "has_sig": false, "md5_digest": "4f417ce902a2a07bfa22eca24c94c54f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5370, "upload_time": "2012-08-09T08:55:44", "url": "https://files.pythonhosted.org/packages/54/3c/c4d60364d6aaa4e7e5e7ae6ee533ded367526ba46cc70bdac51cebe4301c/databag-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "8478f166bb3fc79ee0a0b1666ca390df", "sha256": "4c08c866d584a2499bf2048163be3fcd9682bacb7ffbe846c4be7776a2718b67" }, "downloads": -1, "filename": "databag-0.3.1.tar.gz", "has_sig": false, "md5_digest": "8478f166bb3fc79ee0a0b1666ca390df", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7398, "upload_time": "2012-08-09T09:01:15", "url": "https://files.pythonhosted.org/packages/e1/56/5791f24c1c040c41284454d2bbccb7a4739dfa6ae7b2a60f96f7b4eb1180/databag-0.3.1.tar.gz" } ], "0.3.2-mod": [ { "comment_text": "", "digests": { "md5": "443176c97f4fcaa2c36c8e100f37cce1", "sha256": "9b533b2f2511384af01181607f94fb5f100426e9ec3617335954b101aec82488" }, "downloads": -1, "filename": "databag-0.3.2-mod.tar.gz", "has_sig": false, "md5_digest": "443176c97f4fcaa2c36c8e100f37cce1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7472, "upload_time": "2012-08-09T22:11:52", "url": "https://files.pythonhosted.org/packages/04/65/ab8561bc0934cccec1e3c16af35cdf8c92e544163e51958a1b74e961da24/databag-0.3.2-mod.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "443176c97f4fcaa2c36c8e100f37cce1", "sha256": "9b533b2f2511384af01181607f94fb5f100426e9ec3617335954b101aec82488" }, "downloads": -1, "filename": "databag-0.3.2-mod.tar.gz", "has_sig": false, "md5_digest": "443176c97f4fcaa2c36c8e100f37cce1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7472, "upload_time": "2012-08-09T22:11:52", "url": "https://files.pythonhosted.org/packages/04/65/ab8561bc0934cccec1e3c16af35cdf8c92e544163e51958a1b74e961da24/databag-0.3.2-mod.tar.gz" } ] }