Skip to content

Commit dabee85

Browse files
authored
Merge pull request #13 from supabase/j0_readme_updates
Minor Updates to README
2 parents fd842a1 + 0e77c95 commit dabee85

File tree

1 file changed

+75
-39
lines changed

1 file changed

+75
-39
lines changed

Diff for: README.md

+75-39
Original file line numberDiff line numberDiff line change
@@ -4,110 +4,146 @@
44

55
Supabase client for Python. This mirrors the design of [supabase-js](https://github.com/supabase/supabase-js/blob/master/README.md)
66

7+
## Status
8+
- [x] Alpha: We are testing Supabase with a closed set of customers
9+
- [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.
10+
- [ ] Public Beta: Stable enough for most non-enterprise use-cases
11+
- [ ] Public: Production-ready
12+
13+
We are currently in Public Alpha. Watch "releases" of this repo to get notified of major updates.
14+
15+
<kbd><img src="https://gitcdn.link/repo/supabase/supabase/master/web/static/watch-repo.gif" alt="Watch this repo"/></kbd>
16+
717
## Installation
818

919
**Recomended:** First activate your virtual environment, with your favourites system. For example, we like `poetry` and `conda`!
1020

1121
#### PyPi installation
22+
1223
Now install the package.
24+
1325
```bash
1426
pip install supabase
1527
```
1628

1729
#### Local installation
30+
1831
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.
19-
```bash
32+
33+
```bash
2034
pip install -e .
2135
```
2236

2337
## Usage
38+
2439
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.
40+
2541
```bash
2642
export SUPABASE_URL="my-url-to-my-awesome-supabase-instance"
2743
export SUPABASE_KEY="my-supa-dupa-secret-supabase-api-key"
2844
```
2945

3046
We can then read the keys in the python source code.
47+
3148
```python
3249
import os
3350
from supabase_py import create_client, Client
3451

3552
url: str = os.environ.get("SUPABASE_URL")
3653
key: str = os.environ.get("SUPABASE_KEY")
37-
38-
password = "password"
3954
supabase: Client = create_client(url, key)
40-
user = supabase.auth.sign_up(email, password)
4155
```
4256

57+
Use the supabase client to interface with your database.
58+
4359
### Running Tests
60+
4461
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:
62+
4563
<p align="center">
4664
<img width="720" height="481" src="https://i.ibb.co/Bq7Kdty/db.png">
4765
</p>
4866

49-
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
67+
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
68+
5069
```bash
5170
SUPABASE_TEST_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYxMjYwOTMyMiwiZXhwIjoxOTI4MTg1MzIyfQ.XL9W5I_VRQ4iyQHVQmjG0BkwRfx6eVyYB3uAKcesukg" \
5271
SUPABASE_TEST_URL="https://tfsatoopsijgjhrqplra.supabase.co" \
5372
pytest -x
5473
```
5574

5675
### See issues for what to work on
76+
5777
Rough roadmap:
78+
5879
- [ ] Wrap [Postgrest-py](https://github.com/supabase/postgrest-py/)
5980
- [ ] Wrap [Realtime-py](https://github.com/supabase/realtime-py)
6081
- [x] Wrap [Gotrue-py](https://github.com/J0/gotrue-py)
6182

83+
### Client Library
6284

85+
This is a sample of how you'd use supabase-py. Functions and tests are WIP
6386

64-
### Client Library
65-
This is a sample of how you'd use [supabase-py]. Functions and tests are WIP
87+
## Authenticate
6688

67-
## Authenticate
68-
```
69-
supabase.auth.signUp({
70-
"email": '[email protected]',
71-
"password": 'example-password',
72-
})
73-
```
89+
```python
90+
from supabase_py import create_client, Client
7491

92+
url: str = os.environ.get("SUPABASE_TEST_URL")
93+
key: str = os.environ.get("SUPABASE_TEST_KEY")
94+
supabase: Client = create_client(url, key)
95+
# Create a random user login email and password.
96+
random_email: str = "[email protected]"
97+
random_password: str = "fqj13bnf2hiu23h"
98+
user = supabase.auth.sign_up(email=random_email, password=random_password)
99+
```
75100

76101
## Sign-in
77-
```
78-
supabase.auth.signIn({
79-
"email": '[email protected]',
80-
"password": 'example-password',
81-
})
82-
```
83102

103+
```python
104+
from supabase_py import create_client, Client
84105

85-
## Sign-in(Auth provider). This is not supported yet
86-
```
87-
supabase.auth.signIn({
88-
// provider can be 'github', 'google', 'gitlab', or 'bitbucket'
89-
"provider": 'github'
90-
})
106+
url: str = os.environ.get("SUPABASE_TEST_URL")
107+
key: str = os.environ.get("SUPABASE_TEST_KEY")
108+
supabase: Client = create_client(url, key)
109+
# Sign in using the user email and password.
110+
random_email: str = "[email protected]"
111+
random_password: str = "fqj13bnf2hiu23h"
112+
user = supabase.auth.sign_in(email=random_email, password=random_password)
91113
```
92114

93-
94115
## Managing Data
116+
117+
#### Insertion of Data
118+
```python
119+
from supabase_py import create_client, Client
120+
121+
url: str = os.environ.get("SUPABASE_TEST_URL")
122+
key: str = os.environ.get("SUPABASE_TEST_KEY")
123+
supabase: Client = create_client(url, key)
124+
data = supabase.table("countries").select("*").execute()
125+
assert len(data.get("data", [])) > 0
95126
```
96-
supabase
97-
.from('countries')
98-
.select("
99-
name,
100-
cities (
101-
name
102-
)
103-
")
127+
128+
#### Selection of Data
129+
```python
130+
from supabase_py import create_client, Client
131+
132+
url: str = os.environ.get("SUPABASE_TEST_URL")
133+
key: str = os.environ.get("SUPABASE_TEST_KEY")
134+
supabase: Client = create_client(url, key)
135+
data = supabase.table("countries").select("*").execute()
136+
# Assert we pulled real data.
137+
assert len(data.get("data", [])) > 0
104138
```
105139

106140
## Realtime Changes
107-
```
108-
mySubscription = supabase
109-
.from('countries')
141+
142+
```python
143+
subscription = supabase
144+
.table('countries')
110145
.on('*', lambda x: print(x))
111146
.subscribe()
112-
```
147+
```
148+
113149
See [Supabase Docs](https://supabase.io/docs/guides/client-libraries) for full list of examples

0 commit comments

Comments
 (0)