pocketbase


Namepocketbase JSON
Version 0.14.0 PyPI version JSON
download
home_pagehttps://github.com/vaphes/pocketbase
SummaryPocketBase SDK for python.
upload_time2024-12-05 15:28:42
maintainerNone
docs_urlNone
authorVithor Jaeger
requires_python>=3.9
licenseMIT
keywords pocketbase sdk
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PocketBase Python SDK

[![Tests](https://github.com/vaphes/pocketbase/actions/workflows/tests.yml/badge.svg)](https://github.com/vaphes/pocketbase/actions/workflows/tests.yml)
[![Coverage Status](https://coveralls.io/repos/github/vaphes/pocketbase/badge.svg?branch=master)](https://coveralls.io/github/vaphes/pocketbase?branch=master)

Python client SDK for the <a href="https://pocketbase.io/">PocketBase</a> backend.

This is in early development, and at first is just a translation of <a href="https://github.com/pocketbase/js-sdk">the javascript lib</a> using <a href="https://github.com/encode/httpx/">HTTPX</a>.

---

## Installation

Install PocketBase using PIP:

```shell
python3 -m pip install pocketbase
```

## Usage

The rule of thumb here is just to use it as you would <a href="https://github.com/pocketbase/js-sdk">the javascript lib</a>, but in a pythonic way of course!

```python
from pocketbase import PocketBase  # Client also works the same
from pocketbase.client import FileUpload

client = PocketBase('http://127.0.0.1:8090')

# authenticate as regular user
user_data = client.collection("users").auth_with_password(
    "user@example.com", "0123456789")
# check if user token is valid
user_data.is_valid

# or as admin
admin_data = client.admins.auth_with_password("test@example.com", "0123456789")

# check if admin token is valid
admin_data.is_valid

# list and filter "example" collection records
result = client.collection("example").get_list(
    1, 20, {"filter": 'status = true && created > "2022-08-01 10:00:00"'})

# create record and upload file to image field
result = client.collection("example").create(
    {
        "status": "true",
        "image": FileUpload(("image.png", open("image.png", "rb"))),
    })

# and much more...
```
> More detailed API docs and copy-paste examples could be found in the [API documentation for each service](https://pocketbase.io/docs/api-authentication). Just remember to 'pythonize it' 🙃.

## Development

These are the requirements for local development:

* Python 3.9+
* Poetry (https://python-poetry.org/)

You can install locally:

```shell
poetry install
```

Or can build and generate a package:

```shell
poetry build
```

But if you are using only PIP, use this command:

```shell
python3 -m pip install -e .
```

## Tests

To execute the tests use this command:

```
poetry run pytest
```

## Sandbox integration testing

A lot of real-world integration test against a sandboxed pocketbase instance will be included in the pytest when the sandbox is running (on 127.0.0.1:8090)
to start the sandbox follow the following steps:
```bash
export TMP_EMAIL_DIR=`mktemp -d`  # Export temp dir used for sendmail sandbox
bash ./tests/integration/pocketbase     # Run the pocketbase sandbox (automatically downloads the latest pocketbase instance)
pytest  # Run test including sandbox API integration tests
```
## License

The PocketBase Python SDK is <a href="https://github.com/vaphes/pocketbase/blob/master/LICENCE.txt">MIT licensed</a> code.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/vaphes/pocketbase",
    "name": "pocketbase",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "pocketbase, sdk",
    "author": "Vithor Jaeger",
    "author_email": "vaphes@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ca/8c/589e30935a8c5618ec2a541a14cfd1fafb96c97a94cbe984a46d5664aff7/pocketbase-0.14.0.tar.gz",
    "platform": null,
    "description": "# PocketBase Python SDK\n\n[![Tests](https://github.com/vaphes/pocketbase/actions/workflows/tests.yml/badge.svg)](https://github.com/vaphes/pocketbase/actions/workflows/tests.yml)\n[![Coverage Status](https://coveralls.io/repos/github/vaphes/pocketbase/badge.svg?branch=master)](https://coveralls.io/github/vaphes/pocketbase?branch=master)\n\nPython client SDK for the <a href=\"https://pocketbase.io/\">PocketBase</a> backend.\n\nThis is in early development, and at first is just a translation of <a href=\"https://github.com/pocketbase/js-sdk\">the javascript lib</a> using <a href=\"https://github.com/encode/httpx/\">HTTPX</a>.\n\n---\n\n## Installation\n\nInstall PocketBase using PIP:\n\n```shell\npython3 -m pip install pocketbase\n```\n\n## Usage\n\nThe rule of thumb here is just to use it as you would <a href=\"https://github.com/pocketbase/js-sdk\">the javascript lib</a>, but in a pythonic way of course!\n\n```python\nfrom pocketbase import PocketBase  # Client also works the same\nfrom pocketbase.client import FileUpload\n\nclient = PocketBase('http://127.0.0.1:8090')\n\n# authenticate as regular user\nuser_data = client.collection(\"users\").auth_with_password(\n    \"user@example.com\", \"0123456789\")\n# check if user token is valid\nuser_data.is_valid\n\n# or as admin\nadmin_data = client.admins.auth_with_password(\"test@example.com\", \"0123456789\")\n\n# check if admin token is valid\nadmin_data.is_valid\n\n# list and filter \"example\" collection records\nresult = client.collection(\"example\").get_list(\n    1, 20, {\"filter\": 'status = true && created > \"2022-08-01 10:00:00\"'})\n\n# create record and upload file to image field\nresult = client.collection(\"example\").create(\n    {\n        \"status\": \"true\",\n        \"image\": FileUpload((\"image.png\", open(\"image.png\", \"rb\"))),\n    })\n\n# and much more...\n```\n> More detailed API docs and copy-paste examples could be found in the [API documentation for each service](https://pocketbase.io/docs/api-authentication). Just remember to 'pythonize it' \ud83d\ude43.\n\n## Development\n\nThese are the requirements for local development:\n\n* Python 3.9+\n* Poetry (https://python-poetry.org/)\n\nYou can install locally:\n\n```shell\npoetry install\n```\n\nOr can build and generate a package:\n\n```shell\npoetry build\n```\n\nBut if you are using only PIP, use this command:\n\n```shell\npython3 -m pip install -e .\n```\n\n## Tests\n\nTo execute the tests use this command:\n\n```\npoetry run pytest\n```\n\n## Sandbox integration testing\n\nA lot of real-world integration test against a sandboxed pocketbase instance will be included in the pytest when the sandbox is running (on 127.0.0.1:8090)\nto start the sandbox follow the following steps:\n```bash\nexport TMP_EMAIL_DIR=`mktemp -d`  # Export temp dir used for sendmail sandbox\nbash ./tests/integration/pocketbase     # Run the pocketbase sandbox (automatically downloads the latest pocketbase instance)\npytest  # Run test including sandbox API integration tests\n```\n## License\n\nThe PocketBase Python SDK is <a href=\"https://github.com/vaphes/pocketbase/blob/master/LICENCE.txt\">MIT licensed</a> code.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "PocketBase SDK for python.",
    "version": "0.14.0",
    "project_urls": {
        "Homepage": "https://github.com/vaphes/pocketbase",
        "Repository": "https://github.com/vaphes/pocketbase"
    },
    "split_keywords": [
        "pocketbase",
        " sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6210a1e52639ae82088dd5cba50eb6fcc2e0e8fd0add859a54785b6c16f2a7b9",
                "md5": "c09329ccf5eeb1add53bb594d96bf46c",
                "sha256": "3077f21cd24c5543301e28058bbcb93d2ea5048872cac1669ab4497faab784a8"
            },
            "downloads": -1,
            "filename": "pocketbase-0.14.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c09329ccf5eeb1add53bb594d96bf46c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 27773,
            "upload_time": "2024-12-05T15:28:41",
            "upload_time_iso_8601": "2024-12-05T15:28:41.910085Z",
            "url": "https://files.pythonhosted.org/packages/62/10/a1e52639ae82088dd5cba50eb6fcc2e0e8fd0add859a54785b6c16f2a7b9/pocketbase-0.14.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ca8c589e30935a8c5618ec2a541a14cfd1fafb96c97a94cbe984a46d5664aff7",
                "md5": "48aa6a024061f44757164a54a44aba29",
                "sha256": "154c704964bfaabf17f2c3c7c4ad0869a30e62af9e7208f63f9bb6748805e67b"
            },
            "downloads": -1,
            "filename": "pocketbase-0.14.0.tar.gz",
            "has_sig": false,
            "md5_digest": "48aa6a024061f44757164a54a44aba29",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 17953,
            "upload_time": "2024-12-05T15:28:42",
            "upload_time_iso_8601": "2024-12-05T15:28:42.869697Z",
            "url": "https://files.pythonhosted.org/packages/ca/8c/589e30935a8c5618ec2a541a14cfd1fafb96c97a94cbe984a46d5664aff7/pocketbase-0.14.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-05 15:28:42",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vaphes",
    "github_project": "pocketbase",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pocketbase"
}
        
Elapsed time: 0.47521s