diff --git a/.gitignore b/.gitignore index b6e47617..715b9467 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.idea + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/supabase_py/client.py b/supabase_py/client.py new file mode 100644 index 00000000..3434b5d1 --- /dev/null +++ b/supabase_py/client.py @@ -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"] diff --git a/supabase_py/request_builder.py b/supabase_py/request_builder.py new file mode 100644 index 00000000..1b51be55 --- /dev/null +++ b/supabase_py/request_builder.py @@ -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)