added supabase

This commit is contained in:
n4ze3m
2023-04-11 15:19:39 +05:30
parent a3535bb5c5
commit 00e6d71727
13 changed files with 211 additions and 90 deletions

0
py_server/db/__init__.py Normal file
View File

25
py_server/db/supa.py Normal file
View File

@@ -0,0 +1,25 @@
import supabase
import os
class SupaService:
def __init__(self):
self.supabase_url = os.environ.get("SUPABASE_URL")
self.supabase_key = os.environ.get("SUPABASE_KEY")
self.supabase = supabase.create_client(self.supabase_url, self.supabase_key)
def validate_user(self, token):
user = self.supabase.table("User").select("*").eq("access_token", token).execute()
return user
def save_webiste(self, title: str, icon: str, html: str, url: str, user_id: str):
result = self.supabase.table("Website").insert( {
"title": title,
"icon": icon,
"html": html,
"url": url,
"user_id": user_id
}).execute()
return result