Skip to content

Commit a1b7b7e

Browse files
Create supabase_client.py
1 parent a16426c commit a1b7b7e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎supabase_client.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import os
2+
from dotenv import load_dotenv
3+
from supabase import create_client
4+
5+
# .env file se variables load karo (local testing ke liye)
6+
load_dotenv()
7+
8+
_supabase_client = None
9+
10+
def get_supabase():
11+
global _supabase_client
12+
if _supabase_client is None:
13+
url = os.getenv("SUPABASE_URL")
14+
# Render par hum service role key use karte hain
15+
key = os.getenv("SUPABASE_SERVICE_ROLE_KEY") or os.getenv("SUPABASE_KEY")
16+
17+
if not url or not key:
18+
raise RuntimeError("SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY must be set in environment variables")
19+
20+
_supabase_client = create_client(url, key)
21+
return _supabase_client

0 commit comments

Comments
 (0)