Skip to content

Commit 3c560de

Browse files
Wrap postgrest-py (#4)
1 parent 050e280 commit 3c560de

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.idea
2+
13
# Byte-compiled / optimized / DLL files
24
__pycache__/
35
*.py[cod]

supabase_py/client.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from typing import Optional
2+
3+
DEFAULT_OPTIONS = {
4+
"schema": "public",
5+
"auto_refresh_token": True,
6+
"persist_session": True,
7+
"detect_session_in_url": True,
8+
"headers": {},
9+
}
10+
11+
12+
class SupabaseClient:
13+
"""
14+
creates a new client for use in the browser
15+
"""
16+
17+
def __init__(self, supabase_url, supabase_key, options: Optional[dict] = None):
18+
"""
19+
:param str supabase_url: The unique Supabase URL which is supplied when you create a new project in your
20+
project dashboard.
21+
:param str supabase_key: The unique Supabase Key which is supplied when you create a new project in your project
22+
dashboard.
23+
:param dict options: a dictionary of various config for Supabase
24+
"""
25+
26+
if not supabase_url:
27+
raise Exception("supabase_url is required")
28+
if not supabase_key:
29+
raise Exception("supabase_key is required")
30+
31+
settings = {**DEFAULT_OPTIONS, **options}
32+
self.rest_url = f"{supabase_url}/rest/v1"
33+
self.schema = settings["schema"]

supabase_py/request_builder.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from httpx import AsyncClient
2+
from postgrest_py.request_builder import RequestBuilder
3+
4+
5+
class SupabaseRequestBuilder(RequestBuilder):
6+
def __init__(self, session: AsyncClient, path: str):
7+
super().__init__(session, path)

0 commit comments

Comments
 (0)