From 3743614728085e0b7cf2574ae1d8bca5a2ce0ff8 Mon Sep 17 00:00:00 2001 From: prettyirrelevant Date: Mon, 4 Jan 2021 07:58:10 +0100 Subject: [PATCH 1/3] updated .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) 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] From ba85d9b5a4719b23fcf69f1cd4bca1ea03ba34f4 Mon Sep 17 00:00:00 2001 From: prettyirrelevant Date: Mon, 4 Jan 2021 08:42:38 +0100 Subject: [PATCH 2/3] client and request_builder init --- supabase_py/client.py | 0 supabase_py/request_builder.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 supabase_py/client.py create mode 100644 supabase_py/request_builder.py diff --git a/supabase_py/client.py b/supabase_py/client.py new file mode 100644 index 00000000..e69de29b diff --git a/supabase_py/request_builder.py b/supabase_py/request_builder.py new file mode 100644 index 00000000..e69de29b From c27e381ad921980cf01e7274cda87771ab4d27f3 Mon Sep 17 00:00:00 2001 From: prettyirrelevant Date: Mon, 4 Jan 2021 15:44:39 +0100 Subject: [PATCH 3/3] wrapped RequestBuilder and init SupabaseClient --- supabase_py/client.py | 33 +++++++++++++++++++++++++++++++++ supabase_py/request_builder.py | 7 +++++++ 2 files changed, 40 insertions(+) diff --git a/supabase_py/client.py b/supabase_py/client.py index e69de29b..3434b5d1 100644 --- a/supabase_py/client.py +++ 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 index e69de29b..1b51be55 100644 --- a/supabase_py/request_builder.py +++ 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)