Spaces:
Runtime error
Runtime error
File size: 1,080 Bytes
15c7eff |
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 37 38 |
from dotenv import load_dotenv
import os
load_dotenv()
from supabase import create_client, Client
url: str = os.environ.get("SUPABASE_URL")
key: str = os.environ.get("SUPABASE_KEY")
supabase: Client = create_client(url, key)
# authentication set up
user_email:str = os.environ.get("USER_EMAIL_1")
user_password: str = os.environ.get("USER_PASSWORD_1")
# Sign in the user
auth_response = supabase.auth.sign_in_with_password({"email": user_email, "password": user_password})
# creating a function to insert user info
def insert_user_info(user_info: dict) -> None:
try:
response = supabase.table("user-info").insert(user_info).execute()
return f"'response': {response}"
except Exception as e:
print(e)
if __name__ == "__main__":
new_info = {
"Name": "Timothy Afolami",
"Address": "Lagos, Nigeria",
"Phone Number": "08100450227",
"Email" : "timmyafolami8469@gmail.com"
}
response = insert_user_info(user_info=new_info)
print(response) |