|
4 | 4 |
|
5 | 5 | Supabase client for Python. This mirrors the design of [supabase-js](https://github.com/supabase/supabase-js/blob/master/README.md)
|
6 | 6 |
|
| 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 | + |
7 | 17 | ## Installation
|
8 | 18 |
|
9 | 19 | **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
|
41 | 51 |
|
42 | 52 | url: str = os.environ.get("SUPABASE_URL")
|
43 | 53 | key: str = os.environ.get("SUPABASE_KEY")
|
44 |
| - |
45 |
| -password = "password" |
46 | 54 | supabase: Client = create_client(url, key)
|
47 |
| -user = supabase.auth.sign_up(email, password) |
48 | 55 | ```
|
49 | 56 |
|
| 57 | +Use the supabase client to interface with your database. |
| 58 | + |
50 | 59 | ### Running Tests
|
51 | 60 |
|
52 | 61 | 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
|
78 | 87 | ## Authenticate
|
79 | 88 |
|
80 | 89 | ```python
|
81 |
| -supabase.auth.sign_up({ |
82 |
| - |
83 |
| - "password": 'example-password', |
84 |
| -}) |
| 90 | +from supabase_py import create_client, Client |
| 91 | + |
| 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) |
85 | 99 | ```
|
86 | 100 |
|
87 | 101 | ## Sign-in
|
88 | 102 |
|
89 | 103 | ```python
|
90 |
| -supabase.auth.signIn({ |
91 |
| - |
92 |
| - "password": 'example-password', |
93 |
| -}) |
| 104 | +from supabase_py import create_client, Client |
| 105 | + |
| 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) |
94 | 113 | ```
|
95 | 114 |
|
96 |
| -## Sign-in(Auth provider). This is not supported yet |
| 115 | +## Managing Data |
97 | 116 |
|
| 117 | +#### Insertion of Data |
98 | 118 | ```python
|
99 |
| -supabase.auth.signIn({ |
100 |
| - // provider can be 'github', 'google', 'gitlab', or 'bitbucket' |
101 |
| - "provider": 'github' |
102 |
| -}) |
103 |
| -``` |
| 119 | +from supabase_py import create_client, Client |
104 | 120 |
|
105 |
| -## Managing Data |
| 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 |
| 126 | +``` |
106 | 127 |
|
| 128 | +#### Selection of Data |
107 | 129 | ```python
|
108 |
| -supabase |
109 |
| - .from('countries') |
110 |
| - .select(" |
111 |
| - name, |
112 |
| - cities ( |
113 |
| - name |
114 |
| - ) |
115 |
| - ") |
| 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 |
116 | 138 | ```
|
117 | 139 |
|
118 | 140 | ## Realtime Changes
|
119 | 141 |
|
120 | 142 | ```python
|
121 |
| -mySubscription = supabase |
122 |
| - .from('countries') |
| 143 | +subscription = supabase |
| 144 | + .table('countries') |
123 | 145 | .on('*', lambda x: print(x))
|
124 | 146 | .subscribe()
|
125 | 147 | ```
|
|
0 commit comments