Skip to content

Commit f917b60

Browse files
committed
cosmetics
1 parent 7882598 commit f917b60

File tree

9 files changed

+223
-60
lines changed

9 files changed

+223
-60
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Python 3.7-3.10
4+
name: Tests
55

66
on:
77
push:

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,46 @@
11
# PocketBase Python SDK
22

3-
[![Python 3.7-3.10](https://github.com/vaphes/pocketbase/actions/workflows/python-versions.yml/badge.svg)](https://github.com/vaphes/pocketbase/actions/workflows/python-versions.yml)
3+
[![Tests](https://github.com/vaphes/pocketbase/actions/workflows/tests.yml/badge.svg)](https://github.com/vaphes/pocketbase/actions/workflows/tests.yml)
44

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

77
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>.
88

99
---
1010

11+
## Installation
12+
1113
Install PocketBase using pip:
1214

1315
```shell
1416
$ pip install pocketbase
1517
```
1618

19+
## Usage
20+
21+
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!
22+
23+
```python
24+
from pocketbase import Client
25+
26+
client = Client('http://127.0.0.1:8090')
27+
28+
...
29+
30+
# list and filter "example" collection records
31+
result = client.records.get_list(
32+
"example", 1, 20, {"filter": 'status = true && created > "2022-08-01 10:00:00"'}
33+
)
34+
35+
# authenticate as regular user
36+
user_data = client.users.auth_via_email("[email protected]", "123456")
37+
38+
# or as admin
39+
admin_data = client.admins.auth_via_email("[email protected]", "123456")
40+
41+
# and much more...
42+
```
43+
> 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' 🙃.
44+
45+
1746
<p align="center"><i>The PocketBase Python SDK is <a href="https://github.com/vaphes/pocketbase/blob/master/LICENCE.txt">MIT licensed</a> code.</p>

pocketbase/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__title__ = "pocketbase"
22
__description__ = "PocketBase client SDK for python."
3-
__version__ = "0.2.0"
3+
__version__ = "0.2.1"
44

55

66
from .client import Client, ClientResponseError

pocketbase/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def send(self, path: str, req_config: dict[str:Any]) -> Any:
6666
config.update(req_config)
6767
# check if Authorization header can be added
6868
if self.auth_store.token and (
69-
not "headers" in config or "Authorization" not in config["headers"]
69+
"headers" not in config or "Authorization" not in config["headers"]
7070
):
7171
auth_type = "Admin"
7272
if hasattr(self.auth_store.model, "verified"):

pocketbase/stores/local_auth_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ def __init__(
2828
@property
2929
def token(self) -> str:
3030
data = self._storage_get(self.complete_filepath)
31-
if not data or not "token" in data:
31+
if not data or "token" not in data:
3232
return None
3333
return data["token"]
3434

3535
@property
3636
def model(self) -> User | Admin | None:
3737
data = self._storage_get(self.complete_filepath)
38-
if not data or not "model" in data:
38+
if not data or "model" not in data:
3939
return None
4040
return data["model"]
4141

0 commit comments

Comments
 (0)