Skip to content

Commit 19f6e8e

Browse files
authored
Merge pull request #5 from J0/master
Miscellaneous updates from downstream
2 parents 3c560de + 1ac7232 commit 19f6e8e

13 files changed

+573
-29
lines changed

.gitignore

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
tags
2+
## Vim stuff
3+
# Swap
4+
[._]*.s[a-v][a-z]
5+
!*.svg # comment out if you don't need vector files
6+
[._]*.sw[a-p]
7+
[._]s[a-rt-v][a-z]
8+
[._]ss[a-gi-z]
9+
[._]sw[a-p]
10+
11+
# Session
12+
Session.vim
13+
Sessionx.vim
14+
15+
# Temporary
16+
.netrwhist
17+
*~
18+
# Auto-generated tag files
19+
tags
20+
# Persistent undo
21+
[._]*.un~
122
.idea
223

324
# Byte-compiled / optimized / DLL files
@@ -16,7 +37,6 @@ dist/
1637
downloads/
1738
eggs/
1839
.eggs/
19-
lib/
2040
lib64/
2141
parts/
2242
sdist/

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 Supabase
3+
Copyright (c) 2020 Joel Lee
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+107-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,113 @@
11
# supabase-py
22

3-
Supabase client for Python.
3+
[![Documentation Status](https://readthedocs.org/projects/gotrue-py/badge/?version=latest)](https://gotrue-py.readthedocs.io/en/latest/?badge=latest)
44

5-
### See issues for what to work on
5+
Supabase client for Python. This mirrors the design of [supabase-js](https://github.com/supabase/supabase-js/blob/master/README.md)
66

7-
Rough roadmap:
7+
## Installation
8+
9+
**Recomended:** First activate your virtual environment, with your favourites system. For example, we like `poetry` and `conda`!
10+
11+
#### PyPi installation
12+
Now install the package.
13+
```bash
14+
pip install supabase
15+
```
16+
17+
#### Local installation
18+
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
20+
pip install -e .
21+
```
22+
23+
## Usage
24+
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.
25+
```bash
26+
export SUPABASE_URL="my-url-to-my-awesome-supabase-instance"
27+
export SUPABASE_KEY="my-supa-dupa-secret-supabase-api-key"
28+
```
829

30+
We can then read the keys in the python source code.
31+
```python
32+
import os
33+
from supabase_py import create_client, Client
34+
35+
url: str = os.environ.get("SUPABASE_URL")
36+
key: str = os.environ.get("SUPABASE_KEY")
37+
38+
password = "password"
39+
supabase: Client = create_client(url, key)
40+
user = supabase.auth.sign_up(email, password)
41+
```
42+
43+
### Running Tests
44+
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:
45+
<p align="center">
46+
<img width="720" height="481" src="https://i.ibb.co/Bq7Kdty/db.png">
47+
</p>
48+
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
50+
```bash
51+
SUPABASE_TEST_KEY="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlhdCI6MTYxMjYwOTMyMiwiZXhwIjoxOTI4MTg1MzIyfQ.XL9W5I_VRQ4iyQHVQmjG0BkwRfx6eVyYB3uAKcesukg" \
52+
SUPABASE_TEST_URL="https://tfsatoopsijgjhrqplra.supabase.co" \
53+
pytest -x
54+
```
55+
56+
### See issues for what to work on
57+
Rough roadmap:
958
- [ ] Wrap [Postgrest-py](https://github.com/supabase/postgrest-py/)
10-
- [ ] Write Realtime-py (Use [realtime-js](https://github.com/supabase/realtime-js) as reference implementation) (implementation started by @Jeffery Kwoh @Joel and @Lionell Loh)
11-
- [ ] Wrap Realtime-py (Use [supabase-js](https://github.com/supabase/supabase-js) as reference implementation)
12-
- [ ] Write Gotrue-py (for auth) (Use [gotrue-js](https://github.com/netlify/gotrue-js) as reference implementation)
13-
- [ ] Wrap Gotrue-py
59+
- [ ] Wrap [Realtime-py](https://github.com/supabase/realtime-py)
60+
- [x] Wrap [Gotrue-py](https://github.com/J0/gotrue-py)
61+
62+
63+
64+
### Client Library
65+
This is a sample of how you'd use [supabase-py]. Functions and tests are WIP
66+
67+
## Authenticate
68+
```
69+
supabase.auth.signUp({
70+
"email": '[email protected]',
71+
"password": 'example-password',
72+
})
73+
```
74+
75+
76+
## Sign-in
77+
```
78+
supabase.auth.signIn({
79+
"email": '[email protected]',
80+
"password": 'example-password',
81+
})
82+
```
83+
84+
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+
})
91+
```
92+
93+
94+
## Managing Data
95+
```
96+
supabase
97+
.from('countries')
98+
.select("
99+
name,
100+
cities (
101+
name
102+
)
103+
")
104+
```
105+
106+
## Realtime Changes
107+
```
108+
mySubscription = supabase
109+
.from('countries')
110+
.on('*', lambda x: print(x))
111+
.subscribe()
112+
```
113+
See [Supabase Docs](https://supabase.io/docs/guides/client-libraries) for full list of examples

pyproject.toml

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@
22
name = "supabase-py"
33
version = "0.0.1"
44
description = "Supabase client for Python."
5-
authors = ["Lương Quang Mạnh <[email protected]>"]
5+
authors = ["Joel Lee <[email protected]>"]
66
license = "MIT"
77

88
[tool.poetry.dependencies]
9-
python = "^3.7"
9+
python = "^3.7.1"
1010
postgrest-py = "^0.3.2"
11+
realtime-py="^0.1.0"
12+
gotrue="0.1.2"
13+
pytest="6.2.2"
14+
supabase-realtime-py="0.1.1a0"
1115

1216
[tool.poetry.dev-dependencies]
1317

1418
[build-system]
15-
requires = ["poetry>=0.12"]
19+
requires = [
20+
"poetry>=0.12",
21+
"setuptools>=30.3.0,<50",
22+
]
1623
build-backend = "poetry.masonry.api"

setup.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env python
2+
3+
import setuptools
4+
5+
if __name__ == "__main__":
6+
setuptools.setup()

supabase_py/__init__.py

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Retain module level imports for structured imports in tests etc.
2+
from . import lib
3+
from . import client
4+
5+
# Open up the client and function as an easy import.
6+
from .client import Client, create_client
7+
8+
9+
__version__ = "0.0.1"

0 commit comments

Comments
 (0)