couchbase-helper


Namecouchbase-helper JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/sitzz/python-couchbase-helper
SummarySimple Couchbase helper for Python 3.8+ adding basic functionality
upload_time2025-02-23 14:06:44
maintainerNone
docs_urlNone
authorThomas 'sitzz' Vang
requires_python>=3.8
licenseBSD-3
keywords couchbase cbase cb couchbase-helper
VCS
bugtrack_url
requirements couchbase
Travis-CI No Travis.
coveralls test coverage No coveralls.
            couchbase-helper: A simple helper package for Couchbase operations
=======================================

<!--[![badge](https://img.shields.io/pypi/v/couchbase-helper)](https://pypi.org/project/couchbase-helper/)-->
<!--[![badge](https://img.shields.io/pypi/dm/couchbase-helper)](https://pypi.org/project/couchbase-helper/)-->
<!--[![badge](https://img.shields.io/pypi/l/couchbase-helper)](./LICENSE)-->

--------------------

# Intro

While the [Couchbase](https://pypi.org/project/couchbase/) packages is easy enough to use, sometimes it also just
requires some boilerplate code which becomes tiring to duplicate every time you need to perform simple document
operations. At least, that's what I thought. So, I started creating a simple re-usable script which later became a class
and ... well, here's Couchbase Helper!

Couchbase Helper is currently rather basic and mostly/only support the following operations fully:
* `insert`
* `insert_multi`
* `upsert`
* `upsert_multi`
* `get`
* `get_multi`
* `remove`
* `remove_multi`

It currently also has very basic functionality for view queries (`view_query`) which isn't all that fancy. Follow issue
[#18](https://github.com/sitzz/python-couchbase-helper/issues/18) for updates on this.

An N1ql (SQL++) helper class is also available, which provides chainable methods to create SQL++ queries to select from
indexes.

# Installation

Installation is as you're used to, using your favorite package manager:
```console
$ pip install couchbase-helper
... or
$ uv add couchbase-helper
... or
$ poetry add couchbase-helper
... and so on
```

# Examples

**Basic operations**
```Python
from couchbase_helper import CouchbaseHelper, Session

# Connect to Couchbase server/cluster
session = Session(
    hostname="localhost",
    username="username",
    password="password",
    bucket="bucket",
    timeout=10,
)
cb = CouchbaseHelper(
    session=session,
)

# Insert document
document = {
    "foo": "bar"
}
cb.insert("foo1", document)

# Get document
document = cb.get("foo1")
print(document["foo"])  # bar

# Update document
document["hello"] = "world"
cb.upsert("foo1", document)
```

**SQL++/N1QL examples**
```Python
from couchbase_helper import Session
from couchbase_helper.n1ql import N1ql

# Connect to Couchbase server/cluster
session = Session(
    hostname="localhost",
    username="username",
    password="password",
    bucket="bucket",
    timeout=10,
)
session.connect()
n1ql = N1ql(session=session)

# Select documents where foo=bar
rows = n1ql.where("foo=", "bar").rows()
for row in rows:
    ...

# You can also select specific columns, from a different bucket , scope, or even collection than the session's:
rows = n1ql.select("callsign").from_("travel-sample", "inventory", "airport").where("city=", "San Jose").or_where("city=", "New York").rows()
for row in rows:
    ...
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sitzz/python-couchbase-helper",
    "name": "couchbase-helper",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "couchbase, cbase, cb, couchbase-helper",
    "author": "Thomas 'sitzz' Vang",
    "author_email": "sitzzdk@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/4b/4a/482e725c387775c9d591b3fdfc1038ff1b87a4b6c7071c3a0e26949daf7d/couchbase_helper-0.1.0.tar.gz",
    "platform": null,
    "description": "couchbase-helper: A simple helper package for Couchbase operations\n=======================================\n\n<!--[![badge](https://img.shields.io/pypi/v/couchbase-helper)](https://pypi.org/project/couchbase-helper/)-->\n<!--[![badge](https://img.shields.io/pypi/dm/couchbase-helper)](https://pypi.org/project/couchbase-helper/)-->\n<!--[![badge](https://img.shields.io/pypi/l/couchbase-helper)](./LICENSE)-->\n\n--------------------\n\n# Intro\n\nWhile the [Couchbase](https://pypi.org/project/couchbase/) packages is easy enough to use, sometimes it also just\nrequires some boilerplate code which becomes tiring to duplicate every time you need to perform simple document\noperations. At least, that's what I thought. So, I started creating a simple re-usable script which later became a class\nand ... well, here's Couchbase Helper!\n\nCouchbase Helper is currently rather basic and mostly/only support the following operations fully:\n* `insert`\n* `insert_multi`\n* `upsert`\n* `upsert_multi`\n* `get`\n* `get_multi`\n* `remove`\n* `remove_multi`\n\nIt currently also has very basic functionality for view queries (`view_query`) which isn't all that fancy. Follow issue\n[#18](https://github.com/sitzz/python-couchbase-helper/issues/18) for updates on this.\n\nAn N1ql (SQL++) helper class is also available, which provides chainable methods to create SQL++ queries to select from\nindexes.\n\n# Installation\n\nInstallation is as you're used to, using your favorite package manager:\n```console\n$ pip install couchbase-helper\n... or\n$ uv add couchbase-helper\n... or\n$ poetry add couchbase-helper\n... and so on\n```\n\n# Examples\n\n**Basic operations**\n```Python\nfrom couchbase_helper import CouchbaseHelper, Session\n\n# Connect to Couchbase server/cluster\nsession = Session(\n    hostname=\"localhost\",\n    username=\"username\",\n    password=\"password\",\n    bucket=\"bucket\",\n    timeout=10,\n)\ncb = CouchbaseHelper(\n    session=session,\n)\n\n# Insert document\ndocument = {\n    \"foo\": \"bar\"\n}\ncb.insert(\"foo1\", document)\n\n# Get document\ndocument = cb.get(\"foo1\")\nprint(document[\"foo\"])  # bar\n\n# Update document\ndocument[\"hello\"] = \"world\"\ncb.upsert(\"foo1\", document)\n```\n\n**SQL++/N1QL examples**\n```Python\nfrom couchbase_helper import Session\nfrom couchbase_helper.n1ql import N1ql\n\n# Connect to Couchbase server/cluster\nsession = Session(\n    hostname=\"localhost\",\n    username=\"username\",\n    password=\"password\",\n    bucket=\"bucket\",\n    timeout=10,\n)\nsession.connect()\nn1ql = N1ql(session=session)\n\n# Select documents where foo=bar\nrows = n1ql.where(\"foo=\", \"bar\").rows()\nfor row in rows:\n    ...\n\n# You can also select specific columns, from a different bucket , scope, or even collection than the session's:\nrows = n1ql.select(\"callsign\").from_(\"travel-sample\", \"inventory\", \"airport\").where(\"city=\", \"San Jose\").or_where(\"city=\", \"New York\").rows()\nfor row in rows:\n    ...\n```\n",
    "bugtrack_url": null,
    "license": "BSD-3",
    "summary": "Simple Couchbase helper for Python 3.8+ adding basic functionality",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/sitzz/python-couchbase-helper"
    },
    "split_keywords": [
        "couchbase",
        " cbase",
        " cb",
        " couchbase-helper"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e66482ddd9c6a44add80406524c2ebdf93ed3ba9c509f25722e08050fe14cc83",
                "md5": "1bd4b884de76a8087e1be584b33c29dd",
                "sha256": "1bf7fe54e0cca3b36953272e51d394092cd440933a90b15ac76be62a6a87c136"
            },
            "downloads": -1,
            "filename": "couchbase_helper-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1bd4b884de76a8087e1be584b33c29dd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 16720,
            "upload_time": "2025-02-23T14:06:42",
            "upload_time_iso_8601": "2025-02-23T14:06:42.649846Z",
            "url": "https://files.pythonhosted.org/packages/e6/64/82ddd9c6a44add80406524c2ebdf93ed3ba9c509f25722e08050fe14cc83/couchbase_helper-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4b4a482e725c387775c9d591b3fdfc1038ff1b87a4b6c7071c3a0e26949daf7d",
                "md5": "bddd04f4b6e4b8aef470755627b3ad12",
                "sha256": "6a1cd0e365f76c7b4c6564916ecc3ebfa328b0c1dc24961fb6606740c0002285"
            },
            "downloads": -1,
            "filename": "couchbase_helper-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bddd04f4b6e4b8aef470755627b3ad12",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 16683,
            "upload_time": "2025-02-23T14:06:44",
            "upload_time_iso_8601": "2025-02-23T14:06:44.267011Z",
            "url": "https://files.pythonhosted.org/packages/4b/4a/482e725c387775c9d591b3fdfc1038ff1b87a4b6c7071c3a0e26949daf7d/couchbase_helper-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-23 14:06:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sitzz",
    "github_project": "python-couchbase-helper",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "couchbase",
            "specs": [
                [
                    ">=",
                    "4.0.0"
                ]
            ]
        }
    ],
    "lcname": "couchbase-helper"
}
        
Elapsed time: 1.08179s