{ "info": { "author": "Ardy Dedase", "author_email": "ardy.dedase@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4" ], "description": "===============================\nPyCouchbase\n===============================\n\n.. image:: https://img.shields.io/travis/ardydedase/pycouchbase.svg\n :target: https://travis-ci.org/ardydedase/pycouchbase\n\n.. image:: https://img.shields.io/pypi/v/pycouchbase.svg\n :target: https://pypi.python.org/pypi/pycouchbase\n\n\nWhy add another layer to the SDK?\n------------------------------------\n\n* Inconsistent data types in Couchbase documents can be a real pain.\n* Better management of multiple Couchbase connections.\n* Readability of Couchbase documents in the Python source code while still being able to use Couchbase SDK's operations.\n\nFeatures\n---------------\n\n* This was originally forked from and inspired by couchbasekit_.\n* Validate Couchbase documents.\n* Represent Couchbase documents as Python objects.\n* Easily manage multiple Couchbase connections.\n* Supports `Couchbase Python SDK 2.0`_ operations.\n* There are data retrieval operations that are already included in couchbasekit but I haven't thoroughly tested it with PyCouchbase.\n\n.. _couchbasekit: https://github.com/kirpit/couchbasekit\n.. _Couchbase Python SDK 2.0: http://docs.couchbase.com/developer/python-2.0/introduction.html\n\nInstallation\n---------------\n\nAt the command line::\n\n $ easy_install pycouchbase\n\nOr, if you have virtualenvwrapper installed::\n\n $ mkvirtualenv pycouchbase\n $ pip install pycouchbase\n\nGetting Started\n---------------\n\nLet us go through a simple example.\n\nImport everything we need:\n\n.. code:: python\n\n import datetime\n\n from pycouchbase import Connection\n from pycouchbase import Document, register_view\n from pycouchbase.fields import EmailField, ChoiceField\n\n\nDeclare the Document class:\n\n.. code:: python\n\n # You can define your own field/data type\n\n class Gender(ChoiceField):\n CHOICES = {\n 'M': 'Male',\n 'F': 'Female',\n }\n\n @register_view('dev_authors')\n class Author(Document):\n __bucket_name__ = 'couchbasekit_samples'\n __key_field__ = 'slug' # optional\n doc_type = 'author'\n structure = {\n 'slug': unicode,\n 'first_name': unicode,\n 'last_name': unicode,\n 'gender': Gender,\n 'email': EmailField,\n 'has_book': bool,\n 'age': int,\n 'birthday': datetime.date,\n 'created_at': datetime.datetime,\n }\n default_values = { # optional\n 'has_book': False,\n # don't worry about the timezone info!\n # it's auto assigned as to UTC, so all you have to do is:\n 'created_at': datetime.datetime.utcnow,\n }\n required_fields = ( # optional\n 'slug',\n 'first_name',\n 'last_name',\n 'email',\n )\n\n\nValidate and save your document:\n\n.. code:: python\n\n local_connection = Connection.auth(server='localhost')\n author = Author()\n bucket = author.get_bucket(local_connection)\n\n author.update({\n 'slug': u'douglas_adams',\n 'first_name': u'Douglas',\n 'last_name': u'Adams',\n 'gender': Gender('M'),\n 'email': EmailField('dna@example.com'),\n })\n\n # Try to validate before saving\n try:\n author.validate()\n try:\n rvs = bucket.insert(author.slug, author.encode())\n except KeyExistsError as why:\n print(why) \n except Author.StructureError as why:\n # when the data structure is invalid\n print(why)\n\nSave multiple documents:\n\n.. code:: python\n\n local_connection = Connection.auth(server='localhost')\n author = Author()\n\n list_data = [{\n 'slug': u'douglas_adams',\n 'first_name': u'Douglas',\n 'last_name': u'Adams',\n 'gender': Gender('M'),\n 'email': EmailField('dna@example.com'),\n }, {\n 'slug': u'isaac_asimov',\n 'first_name': u'Isaac',\n 'last_name': u'Asimov',\n 'gender': Gender('M'),\n 'email': EmailField('dna@example.com'),\n }]\n\n try:\n bucket = author.get_bucket(local_connection)\n updated_authors = {}\n\n for d in list_data:\n author.update(d)\n try:\n # validate!\n author.validate()\n updated_authors.update({\n d['slug']: author.encode()\n })\n except author.StructureError as why:\n print(why)\n\n # save multiple data\n rvs = bucket.upsert_multi(updated_authors)\n except CouchbaseNetworkError as why:\n print(why)\n\nManage multiple connections:\n\n.. code:: python\n\n connection_1 = Connection.auth(server='server_1')\n connection_2 = Connection.auth(server='server_2')\n\n # where doc_1 and doc_2 are document objects\n bucket_1 = doc_1.get_bucket(connection_1)\n bucket_2 = doc_2.get_bucket(connection_2)\n\nBucket objects can support any `Couchbase Python SDK 2.0`_ operations:\n\n.. code:: python\n\n bucket_1.get('key_or_id')\n bucket_1.insert('key_or_id', value)\n\nMore about Couchbase SDK's supported operations here: http://docs.couchbase.com/developer/python-2.0/introduction.html\n\n\n\nHistory\n-------\n\n0.1.0 (2015-01-11)\n---------------------\n\n* First release on PyPI.", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ardydedase/pycouchbase", "keywords": "pycouchbase database couchbase python nosql couchbasekit sdk", "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "pycouchbase", "package_url": "https://pypi.org/project/pycouchbase/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pycouchbase/", "project_urls": { "Homepage": "https://github.com/ardydedase/pycouchbase" }, "release_url": "https://pypi.org/project/pycouchbase/0.1.0b1/", "requires_dist": [ "cffi (==1.1.0)", "couchbase (==2.0)", "python-dateutil (==2.1)", "jsonpickle (==0.9.2)" ], "requires_python": null, "summary": "PyCouchbase", "version": "0.1.0b1" }, "last_serial": 1684236, "releases": { "0.1.0.dev1": [ { "comment_text": "", "digests": { "md5": "bdbdfe6701e941e2b5577cd8e44472eb", "sha256": "d8fda8baac5d5c5fc332a2dcf3c7d55f5eb7da9f630bbbb95934a2e248bcee2d" }, "downloads": -1, "filename": "pycouchbase-0.1.0.dev1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bdbdfe6701e941e2b5577cd8e44472eb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 16950, "upload_time": "2015-08-11T07:57:10", "url": "https://files.pythonhosted.org/packages/5d/a3/0583a19ed6639d4ed90e0f7c1450cad03cbbb2957de223def3c1ffae374f/pycouchbase-0.1.0.dev1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f22d64f0faf0cdc8fcd78741c98cedf5", "sha256": "87b057de02d5c500579bde116211b8a0e989a3f9bcc635aec77d9d1a31153263" }, "downloads": -1, "filename": "pycouchbase-0.1.0.dev1.tar.gz", "has_sig": false, "md5_digest": "f22d64f0faf0cdc8fcd78741c98cedf5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23470, "upload_time": "2015-08-11T07:57:15", "url": "https://files.pythonhosted.org/packages/f5/d1/f6e52ae4b57f1f3baf38fb47ab2a6528f5fa4d707f72ee76d470d208d26c/pycouchbase-0.1.0.dev1.tar.gz" } ], "0.1.0b1": [ { "comment_text": "", "digests": { "md5": "5f1107a3acca41f1a531ed265881a5df", "sha256": "4b68e44c60972eb23a0a8586361547d558605197aba1c239d02c9eaf6495f9cd" }, "downloads": -1, "filename": "pycouchbase-0.1.0b1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5f1107a3acca41f1a531ed265881a5df", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 20116, "upload_time": "2015-08-19T16:02:55", "url": "https://files.pythonhosted.org/packages/f7/8f/38883210eda43ee41404e80fa36b07be3ea00dfe29b107ee0bf4786e0dc4/pycouchbase-0.1.0b1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8dc7fc909314e0f3ef447934c4e7379b", "sha256": "a0654364405cb5bd1890823ce1e13099fb496a7e4a5522d38b81b9eb0ac410e2" }, "downloads": -1, "filename": "pycouchbase-0.1.0b1.tar.gz", "has_sig": false, "md5_digest": "8dc7fc909314e0f3ef447934c4e7379b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26164, "upload_time": "2015-08-19T16:03:01", "url": "https://files.pythonhosted.org/packages/31/49/b3c8ffbf083f68f31d68e47a2ba9527496126b364db72d9287102719a3af/pycouchbase-0.1.0b1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5f1107a3acca41f1a531ed265881a5df", "sha256": "4b68e44c60972eb23a0a8586361547d558605197aba1c239d02c9eaf6495f9cd" }, "downloads": -1, "filename": "pycouchbase-0.1.0b1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "5f1107a3acca41f1a531ed265881a5df", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 20116, "upload_time": "2015-08-19T16:02:55", "url": "https://files.pythonhosted.org/packages/f7/8f/38883210eda43ee41404e80fa36b07be3ea00dfe29b107ee0bf4786e0dc4/pycouchbase-0.1.0b1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8dc7fc909314e0f3ef447934c4e7379b", "sha256": "a0654364405cb5bd1890823ce1e13099fb496a7e4a5522d38b81b9eb0ac410e2" }, "downloads": -1, "filename": "pycouchbase-0.1.0b1.tar.gz", "has_sig": false, "md5_digest": "8dc7fc909314e0f3ef447934c4e7379b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26164, "upload_time": "2015-08-19T16:03:01", "url": "https://files.pythonhosted.org/packages/31/49/b3c8ffbf083f68f31d68e47a2ba9527496126b364db72d9287102719a3af/pycouchbase-0.1.0b1.tar.gz" } ] }