From b11118ecfa73c6f721598f5f406850e49b87e86d Mon Sep 17 00:00:00 2001 From: Joel Lee Date: Sun, 4 Apr 2021 00:07:51 +0800 Subject: [PATCH 1/2] Minor Updates to README --- README.md | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index a6c26458..3ffe1f5d 100644 --- a/README.md +++ b/README.md @@ -9,25 +9,32 @@ Supabase client for Python. This mirrors the design of [supabase-js](https://git **Recomended:** First activate your virtual environment, with your favourites system. For example, we like `poetry` and `conda`! #### PyPi installation + Now install the package. + ```bash pip install supabase ``` #### Local installation + You can also installing from after cloning this repo. Install like below to install in Development Mode, which means when you edit the source code the changes will be reflected in your python module. -```bash + +```bash pip install -e . ``` ## Usage + It's usually best practice to set your api key environment variables in some way that version control doesn't track them, e.g don't put them in your python modules! Set the key and url for the supabase instance in the shell, or better yet, use a dotenv file. Heres how to set the variables in the shell. + ```bash export SUPABASE_URL="my-url-to-my-awesome-supabase-instance" export SUPABASE_KEY="my-supa-dupa-secret-supabase-api-key" ``` We can then read the keys in the python source code. + ```python import os from supabase_py import create_client, Client @@ -41,12 +48,15 @@ user = supabase.auth.sign_up(email, password) ``` ### Running Tests + Currently the test suites are in a state of flux. We are expanding our clients tests to ensure things are working, and for now can connect to this test instance, that is populated with the following table: +

-The above test database is a blank supabase instance that has populated the `countries` table with the built in countries script that can be found in the supabase UI. You can launch the test scripts and point to the above test database with the +The above test database is a blank supabase instance that has populated the `countries` table with the built in countries script that can be found in the supabase UI. You can launch the test scripts and point to the above test database with the + ```bash SUPABASE_TEST_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYxMjYwOTMyMiwiZXhwIjoxOTI4MTg1MzIyfQ.XL9W5I_VRQ4iyQHVQmjG0BkwRfx6eVyYB3uAKcesukg" \ SUPABASE_TEST_URL="https://tfsatoopsijgjhrqplra.supabase.co" \ @@ -54,45 +64,47 @@ pytest -x ``` ### See issues for what to work on + Rough roadmap: + - [ ] Wrap [Postgrest-py](https://github.com/supabase/postgrest-py/) - [ ] Wrap [Realtime-py](https://github.com/supabase/realtime-py) - [x] Wrap [Gotrue-py](https://github.com/J0/gotrue-py) +### Client Library +This is a sample of how you'd use supabase-py. Functions and tests are WIP -### Client Library -This is a sample of how you'd use [supabase-py]. Functions and tests are WIP +## Authenticate -## Authenticate -``` -supabase.auth.signUp({ +```python +supabase.auth.sign_up({ "email": 'example@email.com', "password": 'example-password', }) ``` - ## Sign-in -``` + +```python supabase.auth.signIn({ "email": 'example@email.com', "password": 'example-password', }) ``` - ## Sign-in(Auth provider). This is not supported yet -``` + +```python supabase.auth.signIn({ // provider can be 'github', 'google', 'gitlab', or 'bitbucket' "provider": 'github' }) ``` - ## Managing Data -``` + +```python supabase .from('countries') .select(" @@ -104,10 +116,12 @@ supabase ``` ## Realtime Changes -``` + +```python mySubscription = supabase .from('countries') .on('*', lambda x: print(x)) .subscribe() - ``` +``` + See [Supabase Docs](https://supabase.io/docs/guides/client-libraries) for full list of examples From 0e77c9569f1aab537fe4eb4eeaf3fd3ce152d58e Mon Sep 17 00:00:00 2001 From: leonfedden Date: Mon, 5 Apr 2021 18:54:46 +0100 Subject: [PATCH 2/2] update readme --- README.md | 78 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 3ffe1f5d..1aa46df3 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,16 @@ Supabase client for Python. This mirrors the design of [supabase-js](https://github.com/supabase/supabase-js/blob/master/README.md) +## Status +- [x] Alpha: We are testing Supabase with a closed set of customers +- [x] Public Alpha: Anyone can sign up over at [app.supabase.io](https://app.supabase.io). But go easy on us, there are a few kinks. +- [ ] Public Beta: Stable enough for most non-enterprise use-cases +- [ ] Public: Production-ready + +We are currently in Public Alpha. Watch "releases" of this repo to get notified of major updates. + +Watch this repo + ## Installation **Recomended:** First activate your virtual environment, with your favourites system. For example, we like `poetry` and `conda`! @@ -41,12 +51,11 @@ from supabase_py import create_client, Client url: str = os.environ.get("SUPABASE_URL") key: str = os.environ.get("SUPABASE_KEY") -email = "abcdde@gmail.com" -password = "password" supabase: Client = create_client(url, key) -user = supabase.auth.sign_up(email, password) ``` +Use the supabase client to interface with your database. + ### Running Tests Currently the test suites are in a state of flux. We are expanding our clients tests to ensure things are working, and for now can connect to this test instance, that is populated with the following table: @@ -78,48 +87,61 @@ This is a sample of how you'd use supabase-py. Functions and tests are WIP ## Authenticate ```python -supabase.auth.sign_up({ - "email": 'example@email.com', - "password": 'example-password', -}) +from supabase_py import create_client, Client + +url: str = os.environ.get("SUPABASE_TEST_URL") +key: str = os.environ.get("SUPABASE_TEST_KEY") +supabase: Client = create_client(url, key) +# Create a random user login email and password. +random_email: str = "3hf82fijf92@supamail.com" +random_password: str = "fqj13bnf2hiu23h" +user = supabase.auth.sign_up(email=random_email, password=random_password) ``` ## Sign-in ```python -supabase.auth.signIn({ - "email": 'example@email.com', - "password": 'example-password', -}) +from supabase_py import create_client, Client + +url: str = os.environ.get("SUPABASE_TEST_URL") +key: str = os.environ.get("SUPABASE_TEST_KEY") +supabase: Client = create_client(url, key) +# Sign in using the user email and password. +random_email: str = "3hf82fijf92@supamail.com" +random_password: str = "fqj13bnf2hiu23h" +user = supabase.auth.sign_in(email=random_email, password=random_password) ``` -## Sign-in(Auth provider). This is not supported yet +## Managing Data +#### Insertion of Data ```python -supabase.auth.signIn({ - // provider can be 'github', 'google', 'gitlab', or 'bitbucket' - "provider": 'github' -}) -``` +from supabase_py import create_client, Client -## Managing Data +url: str = os.environ.get("SUPABASE_TEST_URL") +key: str = os.environ.get("SUPABASE_TEST_KEY") +supabase: Client = create_client(url, key) +data = supabase.table("countries").select("*").execute() +assert len(data.get("data", [])) > 0 +``` +#### Selection of Data ```python -supabase - .from('countries') - .select(" - name, - cities ( - name - ) - ") +from supabase_py import create_client, Client + +url: str = os.environ.get("SUPABASE_TEST_URL") +key: str = os.environ.get("SUPABASE_TEST_KEY") +supabase: Client = create_client(url, key) +data = supabase.table("countries").select("*").execute() +# Assert we pulled real data. +assert len(data.get("data", [])) > 0 ``` ## Realtime Changes ```python -mySubscription = supabase - .from('countries') +subscription = supabase + .table('countries') .on('*', lambda x: print(x)) .subscribe() ```