concierge-apis / core /interface /supabase_client.py
yashmakan's picture
files added
bf2bf0e
raw
history blame contribute delete
873 Bytes
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")
)