Spaces:
Sleeping
Sleeping
File size: 873 Bytes
bf2bf0e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import os
from dotenv import load_dotenv
from supabase._async.client import create_client as acc, AsyncClient
from supabase.client import create_client, Client
load_dotenv()
class SupabaseConfig:
def __init__(self, url: str, api_key: str):
self.url = url
self.api_key = api_key
async def async_supabase_client(config: SupabaseConfig) -> AsyncClient:
try:
return await acc(config.url, config.api_key)
except Exception as e:
print(f"Error creating Supabase client: {e}")
raise
def create_supabase_client(config: SupabaseConfig) -> Client:
try:
return create_client(config.url, config.api_key)
except Exception as e:
print(f"Error creating Supabase client: {e}")
raise
supabase_config = SupabaseConfig(
url=os.getenv("SUPABASE_URL"),
api_key=os.getenv("SUPABASE_API_KEY")
)
|