File size: 760 Bytes
63e2f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
from dotenv import load_dotenv
from supabase import create_client, Client

load_dotenv()
url: str = os.getenv("SUPABASE_URL")
key: str = os.getenv("SUPABASE_ANON_KEY")
supabase: Client = create_client(url, key)

def add_user(user_id: str, user_data: dict):
    """

    Insert or update a user in the 'users_details' table using the provided user_id and user_data.

    """
    # Add the id field to user_data
    user_data['id'] = user_id


    # Upsert user record (insert or update)
    response = supabase.table('users_details').upsert(user_data).execute()
   
    return response
def search_user(user_id: str):
    response = supabase.table('users_details').select("*").eq("id", user_id).execute()
   
    return response