Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
33 changes: 33 additions & 0 deletions supabase_py/client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
from typing import Optional

DEFAULT_OPTIONS = {
"schema": "public",
"auto_refresh_token": True,
"persist_session": True,
"detect_session_in_url": True,
"headers": {},
}


class SupabaseClient:
"""
creates a new client for use in the browser
"""

def __init__(self, supabase_url, supabase_key, options: Optional[dict] = None):
"""
:param str supabase_url: The unique Supabase URL which is supplied when you create a new project in your
project dashboard.
:param str supabase_key: The unique Supabase Key which is supplied when you create a new project in your project
dashboard.
:param dict options: a dictionary of various config for Supabase
"""

if not supabase_url:
raise Exception("supabase_url is required")
if not supabase_key:
raise Exception("supabase_key is required")

settings = {**DEFAULT_OPTIONS, **options}
self.rest_url = f"{supabase_url}/rest/v1"
self.schema = settings["schema"]
7 changes: 7 additions & 0 deletions supabase_py/request_builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from httpx import AsyncClient
from postgrest_py.request_builder import RequestBuilder


class SupabaseRequestBuilder(RequestBuilder):
def __init__(self, session: AsyncClient, path: str):
super().__init__(session, path)