GithubHelp home page GithubHelp logo

pocketbase's Introduction

PocketBase Python SDK

Tests Coverage Status

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(
    "[email protected]", "0123456789")

# or as admin
admin_data = client.admins.auth_with_password("[email protected]", "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:

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

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:

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 MIT licensed code.

pocketbase's People

Contributors

abyesilyurt avatar dsikes avatar herihermwn avatar joshmcculloch avatar m29h avatar mahfoudh94 avatar paulocoutinhox avatar regisin avatar stafel avatar vaphes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.