PocketBase SDK for python.
Project description
PocketBase Python SDK
Python client SDK for the PocketBase backend.
This is in early development, and at first is just a translation of the javascript lib using HTTPX.
Installation
Install PocketBase using PIP:
python3 -m pip install pocketbase
Usage
The rule of thumb here is just to use it as you would the javascript lib, but in a pythonic way of course!
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. 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:
poetry install
Or can build and generate a package:
poetry build
But if you are using only PIP, use this command:
python3 -m pip install -e .
Tests
To execute the tests use this command:
poetry run pytest
License
The PocketBase Python SDK is MIT licensed code.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pocketbase-0.8.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98c739779c209aeaa9a964d5da556b81b5c31c26c6f18e981059301a1bea1433 |
|
MD5 | 86c4d5a7c8b7c5af2c2bfc6f4802c132 |
|
BLAKE2b-256 | a26378ced5a21610ce045497f5c9650c8ddae5270543e60ec1480710cbabfa10 |