pocketbase


Namepocketbase JSON
Version 0.10.0 PyPI version JSON
download
home_pagehttps://github.com/vaphes/pocketbase
SummaryPocketBase SDK for python.
upload_time2024-02-08 13:33:13
maintainer
docs_urlNone
authorVithor Jaeger
requires_python>=3.7,<4.0
license
keywords pocketbase sdk
VCS
bugtrack_url
requirements httpx
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")

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

# 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.7+
* 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": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "pocketbase,sdk",
    "author": "Vithor Jaeger",
    "author_email": "vaphes@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9c/07/46363382a06f559122839b1c29b90efc29a99d7f1edfa8b2d8b25e52af0e/pocketbase-0.10.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\n# or as admin\nadmin_data = client.admins.auth_with_password(\"test@example.com\", \"0123456789\")\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.7+\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\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "PocketBase SDK for python.",
    "version": "0.10.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/vaphes/pocketbase/issues",
        "Homepage": "https://github.com/vaphes/pocketbase",
        "Repository": "https://github.com/vaphes/pocketbase"
    },
    "split_keywords": [
        "pocketbase",
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "800ec5f7af1e191dd7e23201522c1f6a1484b8c7de1040ae3471b75808101dcc",
                "md5": "9ad18e6fb942328cd9194f1a3dc69160",
                "sha256": "b7d55cd2953848303c141fe1b84340d41aea27511542279c9d215544157356ef"
            },
            "downloads": -1,
            "filename": "pocketbase-0.10.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9ad18e6fb942328cd9194f1a3dc69160",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 23908,
            "upload_time": "2024-02-08T13:33:11",
            "upload_time_iso_8601": "2024-02-08T13:33:11.800012Z",
            "url": "https://files.pythonhosted.org/packages/80/0e/c5f7af1e191dd7e23201522c1f6a1484b8c7de1040ae3471b75808101dcc/pocketbase-0.10.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9c0746363382a06f559122839b1c29b90efc29a99d7f1edfa8b2d8b25e52af0e",
                "md5": "60d0d4c5c7aa6227d6348333d7634a29",
                "sha256": "cd6a8127095c26cbb0c05baeb215e5b400eb946ee06ab5a71a34ebf719af41fa"
            },
            "downloads": -1,
            "filename": "pocketbase-0.10.0.tar.gz",
            "has_sig": false,
            "md5_digest": "60d0d4c5c7aa6227d6348333d7634a29",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 15498,
            "upload_time": "2024-02-08T13:33:13",
            "upload_time_iso_8601": "2024-02-08T13:33:13.618139Z",
            "url": "https://files.pythonhosted.org/packages/9c/07/46363382a06f559122839b1c29b90efc29a99d7f1edfa8b2d8b25e52af0e/pocketbase-0.10.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-08 13:33:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "vaphes",
    "github_project": "pocketbase",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "httpx",
            "specs": [
                [
                    ">=",
                    "0.23.0"
                ]
            ]
        }
    ],
    "lcname": "pocketbase"
}
        
Elapsed time: 0.18542s