{ "info": { "author": "Alberto Planas", "author_email": "aplanas@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Other Environment", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Topic :: Database", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Tokyo Cabinet (http://1978th.net/tokyocabinet/) is a modern\nimplementation of DBM database. Mikio Hirabayashi (the author of Tokyo\nCabinet) describe the project as::\n\n Tokyo Cabinet is a library of routines for managing a database. The\n database is a simple data file containing records, each is a pair of\n a key and a value. Every key and value is serial bytes with variable\n length. Both binary data and character string can be used as a key\n and a value. There is neither concept of data tables nor data\n types. Records are organized in hash table, B+ tree, or fixed-length\n array.\n\nThe py-tcdb project is an interface to the library using the ctypes\nPython module and provides a two-level access to TC functions: a low\nlevel and a high level.\n\nLow Level API\n-------------\n\nWe can interface with TC library using directly the tc module. This\nmodule declare all functions and data types. For example, if we want\nto create a HDB (hash database object) we can write::\n\n from tcdb import tc\n from tcdb import hdb\n\n db = tc.hdb_new()\n\n if not tc.hdb_open(db, 'example.tch', hdb.OWRITER|hdb.OCREAT):\n print tc.hdb_errmsg(tc.hdb_ecode(db))\n\n if not tc.hdb_put2(db, 'key', 'value'):\n print tc.hdb_errmsg(tc.hdb_ecode(db))\n\n v = tc.hdb_get2(db, 'key')\n\n print 'VALUE:', v.value\n\n tc.hdb_close(db)\n tc.hdb_del(db)\n\nThe low level API works with ctypes types (like c_char_p or c_int).\n\nHigh Level API\n--------------\n\nFor each kind of database type allowed in TC, we have a Python class\nthat encapsulate all the functionality. For every class we try to\nemulate the bsddb Python module interface. This interface is quite\nsimilar to a dict data type with persistence.\n\nAlso, for HDB, DBD and FDB databases we have a simple version,\ndesigned to work only with strings. This version is faster than\nno-simple ones: it avoids serialization, data conversions (in Python\narena) and use a different way for call C functions. Use the 'simple'\nclass if you want speed and only need string management.\n\nWe also try to improve this API. For example, we can work with\ntransactions using the with Python keyword.\n\nHash Database\n~~~~~~~~~~~~~\n\nWe can use the HDB class to create and manage TC hash databases. This\nclass behaves like a dictionary object, but we can use put and get\nmethods in order to have more control over the stored data. In a hash\ndatabase we can store serialized Python objects as a key or as a\nvalue, or raw data (that can be retrieved from the database using C,\nLua, Perl or Java).\n\n::\n\n from tcdb import hdb\n\n # The open method can change other params like cache or\n # auto defragmentation steep.\n db = hdb.HDB()\n db.open('example.tch')\n\n # Store pickled object in the database\n db['key'] = 10\n assert type(db['key']) == int\n\n db['key'] = 1+1j\n assert type(db['key']) == complex\n\n db[1+1j] = 'text'\n assert type(db[1+1j]) == str\n\n # If we use put/get, we can store raw data\n # Equiv. to use db.put_int('key', 10, as_raw=True)\n db.put('key', 10, raw_key=True, raw_value=True)\n # Equiv. to use db.get_int('key', as_raw=True)\n assert db.get('key', raw_key=True, value_type=int) == 10\n\n # We can remove records using 'del' keyword\n # or out methods\n db.out('key', as_raw=True)\n\n # We can iterate over the records.\n for key, value in db.iteritems():\n print key, ':', value\n\n # The 'with' keywork works as expected\n with db:\n db[10] = 'ten'\n assert db[10] == 'ten'\n raise Exception\n\n # Because we abort the transaction, we don't\n # have the new record\n try:\n db[10]\n except KeyError:\n pass\n\n\nB+ Tree Database\n~~~~~~~~~~~~~~~~\n\nWe can use the class BDB to create and manage B+ tree TC\ndatabases. The API is quite similar to the HDB one. One thing that we\ncan do with BDB class is that we can access using a Cursor. With range\nwe can access to a set of ordered keys in a efficient way, and with\nCursor object we can navigate over the database.\n\nFixed-length Database\n~~~~~~~~~~~~~~~~~~~~~\n\nFDB class can create and manage a fixed-length array database. In this\nkind of database we can only use int keys, like in a dynamic array.\n\nTable Database\n~~~~~~~~~~~~~~\n\nTokyo Cabinet can use a variation of a hash database to store\ntable-like object. In Python we can use a dict object to represent a\nsingle table. With THD we can store these tables and make queries\nusing Query object.\n\n::\n\n from tcdb import tdb\n\n # The open method can change other params like cache or\n # auto defragmentation steep.\n db = tdb.TDB()\n db.open('example.tct')\n\n # Store directly a new table\n alice = {'user': 'alice', 'name': 'Alice', 'age': 23}\n db['pk'] = alice\n assert db['pk'] == alice\n assert type(db['pk']['age']) == int\n\n # If we use put/get, we can store raw data\n db.put('pk', alice, raw_key=True, raw_cols=True)\n # Equiv. to use db.get_col_int('pk', 'age', raw_key=True)\n schema = {'user': str, 'name': str, 'age': int}\n assert db.get('pk', raw_key=True, schema=schema)['age'] == 23\n\n # We can remove records using 'del' keyword\n # or out methods\n del db['pk']\n\nAbstract Database\n~~~~~~~~~~~~~~~~~\n\nFor completeness, we include the ADB abstract interface for accessing\nhash, B+ tree, fixed-length and table database objects.", "description_content_type": null, "docs_url": null, "download_url": "http://py-tcdb.googlecode.com/files/py-tcdb-0.4.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://code.google.com/p/py-tcdb/", "keywords": "tokyo cabinet,ctypes,database", "license": "LGPL", "maintainer": null, "maintainer_email": null, "name": "py-tcdb", "package_url": "https://pypi.org/project/py-tcdb/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/py-tcdb/", "project_urls": { "Download": "http://py-tcdb.googlecode.com/files/py-tcdb-0.4.tar.gz", "Homepage": "http://code.google.com/p/py-tcdb/" }, "release_url": "https://pypi.org/project/py-tcdb/0.4/", "requires_dist": null, "requires_python": null, "summary": "A Python wrapper for Tokyo Cabinet database using ctypes.", "version": "0.4" }, "last_serial": 285795, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "a98401fc6053f5a4546fcc6eef3d81f9", "sha256": "7123e2a272054a9d3641d0b573869ff6469af04ccc98af5544c9a981e7276825" }, "downloads": -1, "filename": "py-tcdb-0.1.tar.gz", "has_sig": false, "md5_digest": "a98401fc6053f5a4546fcc6eef3d81f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 69200, "upload_time": "2010-04-01T21:24:40", "url": "https://files.pythonhosted.org/packages/f7/db/3c9e9449e15f2cd3712b140f9689e5771083446aa152d61bf09e5e62df68/py-tcdb-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "86e8dd63afd5823e550d3737ee8a898c", "sha256": "c8ae100918776d3ca262679373effaf02ae009f68a1fed1a7577ae9b2cacf18a" }, "downloads": -1, "filename": "py-tcdb-0.2.tar.gz", "has_sig": false, "md5_digest": "86e8dd63afd5823e550d3737ee8a898c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 70148, "upload_time": "2010-04-10T12:19:18", "url": "https://files.pythonhosted.org/packages/e0/07/9236e1ab5992fd975a1932a2cba0e8158826a4a9fbd162fdd25fd4560af1/py-tcdb-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "8a5c87833407528dd305dc159760c8ab", "sha256": "ac3d528e5748c1fbd4a4a9355d1db68fe16f035cd6c6d3376357f2ad8e5c994c" }, "downloads": -1, "filename": "py-tcdb-0.3.tar.gz", "has_sig": false, "md5_digest": "8a5c87833407528dd305dc159760c8ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 73384, "upload_time": "2010-04-28T11:38:49", "url": "https://files.pythonhosted.org/packages/8d/fe/2e1d73c6f76862f1e20c757ac9cc5377b33a9814c7fd9bb5e05f9632313f/py-tcdb-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "6ee0569dc4403397ddc0dbf9e9b1440e", "sha256": "535feeebec04ae23ee42412e28a5f551390d01bfa63306ac2fcad285d8fab283" }, "downloads": -1, "filename": "py-tcdb-0.4.tar.gz", "has_sig": false, "md5_digest": "6ee0569dc4403397ddc0dbf9e9b1440e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 73721, "upload_time": "2011-03-28T19:17:20", "url": "https://files.pythonhosted.org/packages/84/b9/bc9225cefae59f42c639b228fb8f66111855cc17f5b3f26204581286e91c/py-tcdb-0.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "6ee0569dc4403397ddc0dbf9e9b1440e", "sha256": "535feeebec04ae23ee42412e28a5f551390d01bfa63306ac2fcad285d8fab283" }, "downloads": -1, "filename": "py-tcdb-0.4.tar.gz", "has_sig": false, "md5_digest": "6ee0569dc4403397ddc0dbf9e9b1440e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 73721, "upload_time": "2011-03-28T19:17:20", "url": "https://files.pythonhosted.org/packages/84/b9/bc9225cefae59f42c639b228fb8f66111855cc17f5b3f26204581286e91c/py-tcdb-0.4.tar.gz" } ] }