{ "info": { "author": "Andrew Kubera", "author_email": "andrewkubera@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Database" ], "description": "\nLevelPy\n=======\n\nA pythonic interface to the `LevelDB`_ database.\n\nAbout\n-----\n\nLevelPy is a project that does not directly access a LevelDB instance, but\nintends to be a thin wrapper around other implementations, providing a simple\nand pythonic interface to the lower level database.\n\n**LevelPy alone does *NOT* provide access to a database, nor does it declare\none as a dependency. It is up to YOU to choose and install such a package.**\n\nIn addition to the pythonic interface, LevelPy database objects adhere to the\n`LevelDB API`_, which uses uppercase methods such as 'Get'. Any objects which\nprovide this interface interacts directly to the underlying database object, so\nthese expect python bytes objects for keys and values.\n\n\nUsage\n-----\n\nConstructor\n~~~~~~~~~~~\n\nTo create a 'connection' to a leveldb database, use the ``LevelPy.LevelDB``\nclass, providing a path and, optionally, the *full* classname (package + class)\nof the backend to use. The default class is ``leveldb.LevelDB``, using the\n`py-leveldb `_ interface.\n\nYou can also give a class as the second parameter, which is interpreted to be\nthe *type* of the connection to create. This is called with the path and\nexpanded keyword arguments. Similarly, any callable can be used as the second\nparameter, and the constructor will forward the path and any keyword arguments\nto it (the database instance **MUST** be returned by the function).\n\nAlternatively, you can create a separate leveldb connection and pass this to the\nlevelpy.LevelDB constructor. If the first parameter is not a string, it is\nassumed to be an (already connected) backend, and the 'backend class' parameter\nis ignored.\n\nexamples:\n\n.. code:: python\n\n from levelpy import LevelDB\n\n db = LevelDB('/path/to/db') # use the default leveldb.LevelDB backend\n --------------------\n db = LevelDB('/path/to/db', 'plyvel.DB', error_if_exists=True) # use the Plyvel backend w/ keyword\n --------------------\n db = LevelDB('/path/to/db', 'my.custom.leveldb.DATABASE') # use your own backend\n --------------------\n cls = leveldb.LevelDB\n db = LevelDB('/path/to/db', cls) # use a specific class to create an instance\n --------------------\n db = LevelDB(cnx) # use an already created leveldb connection (backend string is ignored)\n\nlevelpy.LevelDB will import the package and store an instance of this class,\nforwarding any keyword arguments to the constructor.\n\nOf course, there is no absolute standard interface so there is no guarantee\nthat all implementations will work. Currently this class assumes that all the\nstandard functionality of the original implementation of leveldb is exposed as\ncapitalized method names: ``db.Get(...)`` ``db.Put(...)`` etc. LevelPy's\nLevelDB class aliases these methods to expose a 1-1 interface of the wrapper\nand backend (if they exist). If the backend you wish to use has a different\nconvention, simply set the aliased methods after creating the connection:\n``db.Get = db._db.retrieve_value`` (access the backend database is provided by\nthe ``_db`` attribute).\n\n\nAccess\n~~~~~~\n\nAs LevelDB is really just a big key-value store, LevelPy implements a\ndict-interface to the database (using the [] operators).\n\n.. code:: python\n\n item = db['itemkey'] # store value with key 'itemkey' as item\n db['something'] = 'else' # store value 'else' with key 'something'\n\n a_to_b = db['a':'b'] # get all items between 'a' and 'b' (inclusive)\n\n has_5 = '5' in db # tests if '5' is a key in the database\n\nAs mentioned in Constructor, such access is also provided by the ``Get`` &\n``Put`` members.\n\nIteration\n~~~~~~~~~\n\nKeeping the database dictlike, LevelPy exposes the methods items(), keys(),\nvalues(), which provides generators to iterate over the expected items.\n\n.. code:: python\n\n keystr = ' '.join(key for key in db.keys())\n\n for k, v in db.items():\n print(k, '->', v)\n\n\nClasses\n~~~~~~~\n\nLevelpy introduces some specialized classes to solve common problems while\nworking with the database.\n\n\nLevelDB\n^^^^^^^\n\nLevelDB is the main class responsible for loading and querying the database.\nA \"real\" leveldb library/class must be used to actually handle the file io.\nTo make your own, simply write a class that implements the LevelDB API.\n\n\nViews\n^^^^^\n\nViews are read-only structures that are built with a prefix which is\nautomatically added to any request. Views may contain other views, creating\nsmaller slices of the full database.\n\nViews provide the levelpy reading-interface: get and iteration.\n\n\nSublevels\n^^^^^^^^^\n\nSublevels are like views but provide full read-write support to the database.\nThe user may create sublevels within a sublevel for more specific requests.\nViews may be created from sublevels, but a sublevel cannot be created from a\nview, as they are read only.\n\nSublevels provide the levelpy read and write interfaces: get, put, delete,\niteration, batch writes.\n\n\nSerializer\n^^^^^^^^^^\n\nLevelDB requires keys and values in the database to be python byte objects, so\nall other types (such as strings) must be encoded to bytes upon request or\nstorage. LevelPy provides a serialization module with functions that implement\nvarious encoding/decoding schemes. Most LevelPy database objects have a\nvalue_encoding parameter in the constructor; if this is a string, it searches\nthe Serializer.transform_dict dictionary for the encode/decode pair with the\nstring. Alternatively, you can supply a tuple of 2 callables which encode\nincoming objects to bytes, and decode bytes into objects. This, mixed with\nsublevels, provide an excelent method to store countless different types in\na single database, with automatic type retrieval.\n\nBy default the Serializer provides string encoding (\"utf8\"), trivial binary\nencoding (\"bin\"), arbitrary json object encoding for dicts (\"json\"), and the\nmore efficient msgpack serialization library (\"msgpack\", must be installed\nseperately)\n\nCustom serialization keys may be added to the transform_dict, for easy access\nto custom serializations. It is recommended to call Serializer.update() after\nmodifying the transform_dict, which updates the Serializer's encode and decode\ndictionaries.\n\n\n.. _LevelDB: http://leveldb.org/\n.. _LevelDB API: http://leveldb.googlecode.com/svn/trunk/doc/index.html\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/akubera/levelpy/archive/v0.3.2.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/akubera/levelpy", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "levelpy", "package_url": "https://pypi.org/project/levelpy/", "platform": "all", "project_url": "https://pypi.org/project/levelpy/", "project_urls": { "Download": "https://github.com/akubera/levelpy/archive/v0.3.2.tar.gz", "Homepage": "https://github.com/akubera/levelpy" }, "release_url": "https://pypi.org/project/levelpy/0.3.2/", "requires_dist": null, "requires_python": null, "summary": "A pythonic interface to the LevelDB database.", "version": "0.3.2" }, "last_serial": 1846071, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "4d9ea2b85f25ba42ca8f40aed71afb7c", "sha256": "441157dd22f067c0f51c14403ebf34adaa36db15e01ba46f85bef050c5703378" }, "downloads": -1, "filename": "levelpy-0.1.0.tar.gz", "has_sig": false, "md5_digest": "4d9ea2b85f25ba42ca8f40aed71afb7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8309, "upload_time": "2015-11-06T21:15:45", "url": "https://files.pythonhosted.org/packages/58/ee/169a00fda27c8d3ba611da418bb35e891db8965a67b389f66d0aaae45df4/levelpy-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "c8f1bdbb6981b615735fb6a7fde82dff", "sha256": "d8ee41896f0578c4c2054cc3502c459b5ed261010cd671cca462af27ae9b36a8" }, "downloads": -1, "filename": "levelpy-0.2.0.tar.gz", "has_sig": false, "md5_digest": "c8f1bdbb6981b615735fb6a7fde82dff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9061, "upload_time": "2015-11-13T07:52:52", "url": "https://files.pythonhosted.org/packages/12/42/c4927c26143c6656d8895ba5786a759b61e28ea99d120dab86364d74bded/levelpy-0.2.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "e92684507acd5212feba67e76cbf7fb0", "sha256": "594eb629c8a14fcd8c94ba7cf7521553ecf957677d7b9ed84250559c5529c34b" }, "downloads": -1, "filename": "levelpy-0.3.1.tar.gz", "has_sig": false, "md5_digest": "e92684507acd5212feba67e76cbf7fb0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8957, "upload_time": "2015-11-24T00:13:07", "url": "https://files.pythonhosted.org/packages/0a/fd/3df41555b03462fc8bdef77491a8fbe79dd32772060778f33845c8199e06/levelpy-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "9fe5b015a6057f89c94e82ccee055262", "sha256": "9d4b6683093d575dd6cedd8206a76a0187085d2c75f6251889ea50b3c3f4f3fa" }, "downloads": -1, "filename": "levelpy-0.3.2.tar.gz", "has_sig": false, "md5_digest": "9fe5b015a6057f89c94e82ccee055262", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10420, "upload_time": "2015-12-04T04:54:36", "url": "https://files.pythonhosted.org/packages/9e/fc/3ba18ef2691e4ec36a523416b3ee6d4bf663b1d4edc93ce4f22e42f562b2/levelpy-0.3.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9fe5b015a6057f89c94e82ccee055262", "sha256": "9d4b6683093d575dd6cedd8206a76a0187085d2c75f6251889ea50b3c3f4f3fa" }, "downloads": -1, "filename": "levelpy-0.3.2.tar.gz", "has_sig": false, "md5_digest": "9fe5b015a6057f89c94e82ccee055262", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10420, "upload_time": "2015-12-04T04:54:36", "url": "https://files.pythonhosted.org/packages/9e/fc/3ba18ef2691e4ec36a523416b3ee6d4bf663b1d4edc93ce4f22e42f562b2/levelpy-0.3.2.tar.gz" } ] }