feat: Add supabase client skeleton
This commit is contained in:
parent
203aa79470
commit
b80efc6d06
5 changed files with 515 additions and 14 deletions
|
|
@ -20,3 +20,22 @@ class AiConfig:
|
|||
raise ValueError(f"{API_KEY} cannot be empty")
|
||||
|
||||
return cls(**{"API_KEY": API_KEY})
|
||||
|
||||
|
||||
@dataclass
|
||||
class SupaConfig:
|
||||
URL: str
|
||||
KEY: str
|
||||
|
||||
@classmethod
|
||||
def from_env(cls) -> "SupaConfig":
|
||||
URL = os.getenv("SUPABASE_URL", "")
|
||||
KEY = os.getenv("SUPABASE_KEY", "")
|
||||
|
||||
values: dict[str, str] = {"URL": URL, "KEY": KEY}
|
||||
|
||||
for name, val in values.items():
|
||||
if not val:
|
||||
raise ValueError(f"SUPABASE_{name} cannot be empty")
|
||||
|
||||
return cls(**values)
|
||||
|
|
|
|||
10
prophet/infra/improvement_supa_repo.py
Normal file
10
prophet/infra/improvement_supa_repo.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from supabase import Client, create_client
|
||||
|
||||
from prophet.config import SupaConfig
|
||||
|
||||
c = SupaConfig.from_env()
|
||||
supabase: Client = create_client(c.URL, c.KEY)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(supabase)
|
||||
Loading…
Add table
Add a link
Reference in a new issue