Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous updates from downstream #5

Merged
merged 34 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c0aa913
Initial commit
Jan 28, 2021
09e731f
Add method stubs
Jan 28, 2021
adfb623
Add rpc function
Jan 29, 2021
3b0bb60
Update imports
Jan 30, 2021
f0f6d06
Add supporting files
Jan 30, 2021
bd5d03b
Add auth client wrapper
Jan 30, 2021
2fc2747
Refactor and format with black
Jan 31, 2021
20106ce
Add _from functions, refactor
Jan 31, 2021
afa8189
Rename files to align with python convention
Feb 2, 2021
2a9c171
Add realtime methods
Feb 3, 2021
0884897
Update README.md
Feb 5, 2021
85c4b52
Enable and manually test auth
Feb 5, 2021
e06b143
Document client and query builder
Feb 5, 2021
b1417b7
ignore vim tags
fedden Feb 5, 2021
30b486a
add version to package
fedden Feb 5, 2021
7edf954
add setup.py to enable "pip install -e . " installs
fedden Feb 5, 2021
97f9162
cleaning up a little and making more pythonic
fedden Feb 5, 2021
9248cf2
improve readme
fedden Feb 5, 2021
6c9e99c
add shim
fedden Feb 5, 2021
c1bc0b1
rm unused library
fedden Feb 5, 2021
db71ab4
change import
fedden Feb 5, 2021
290bebb
add setuptools
fedden Feb 6, 2021
20d2404
stepping through code, slightly changing codebase to reflect python i…
fedden Feb 6, 2021
d524e0c
tests pass
fedden Feb 6, 2021
0739a2f
remove whitespace
fedden Feb 6, 2021
1df7fc9
ignore vim stuff
fedden Feb 6, 2021
0b7a164
add new tests
fedden Feb 6, 2021
97100ad
improve documetnation and add test (doesnt pass yet)
fedden Feb 6, 2021
4c13a4f
return dicts
fedden Feb 6, 2021
b641029
improve documentation
fedden Feb 6, 2021
255bb71
more doc
fedden Feb 7, 2021
ccb88f8
spelling
fedden Feb 7, 2021
0dc431d
Merge pull request #1 from fedden/master
J0 Feb 7, 2021
1ac7232
Merge branch 'master' into master
J0 Feb 7, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
tags
## Vim stuff
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
.idea

# Byte-compiled / optimized / DLL files
Expand All @@ -16,7 +37,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Supabase
Copyright (c) 2020 Joel Lee

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
114 changes: 107 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,113 @@
# supabase-py

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

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

Rough roadmap:
## Installation

**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
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

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)
```

### 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:
<p align="center">
<img width="720" height="481" src="https://i.ibb.co/Bq7Kdty/db.png">
</p>

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" \
pytest -x
```

### See issues for what to work on
Rough roadmap:
- [ ] Wrap [Postgrest-py](https://github.com/supabase/postgrest-py/)
- [ ] Write Realtime-py (Use [realtime-js](https://github.com/supabase/realtime-js) as reference implementation) (implementation started by @Jeffery Kwoh @Joel and @Lionell Loh)
- [ ] Wrap Realtime-py (Use [supabase-js](https://github.com/supabase/supabase-js) as reference implementation)
- [ ] Write Gotrue-py (for auth) (Use [gotrue-js](https://github.com/netlify/gotrue-js) as reference implementation)
- [ ] Wrap Gotrue-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

## Authenticate
```
supabase.auth.signUp({
"email": 'example@email.com',
"password": 'example-password',
})
```


## Sign-in
```
supabase.auth.signIn({
"email": 'example@email.com',
"password": 'example-password',
})
```


## Sign-in(Auth provider). This is not supported yet
```
supabase.auth.signIn({
// provider can be 'github', 'google', 'gitlab', or 'bitbucket'
"provider": 'github'
})
```


## Managing Data
```
supabase
.from('countries')
.select("
name,
cities (
name
)
")
```

## Realtime Changes
```
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
13 changes: 10 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
name = "supabase-py"
version = "0.0.1"
description = "Supabase client for Python."
authors = ["Lương Quang Mạnh <luongquangmanh85@gmail.com>"]
authors = ["Joel Lee <joel@joellee.org>"]
license = "MIT"

[tool.poetry.dependencies]
python = "^3.7"
python = "^3.7.1"
postgrest-py = "^0.3.2"
realtime-py="^0.1.0"
gotrue="0.1.2"
pytest="6.2.2"
supabase-realtime-py="0.1.1a0"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
requires = [
"poetry>=0.12",
"setuptools>=30.3.0,<50",
]
build-backend = "poetry.masonry.api"
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python

import setuptools

if __name__ == "__main__":
setuptools.setup()
9 changes: 9 additions & 0 deletions supabase_py/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Retain module level imports for structured imports in tests etc.
from . import lib
from . import client

# Open up the client and function as an easy import.
from .client import Client, create_client


__version__ = "0.0.1"
Loading