mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-09-11 14:36:35 +03:00
create commands for db create, update, select, delete
This commit is contained in:
parent
d6ebb00f86
commit
549d86bdad
38
backend/core/utils/db_commands.py
Normal file
38
backend/core/utils/db_commands.py
Normal file
@ -0,0 +1,38 @@
|
||||
from typing import Optional
|
||||
|
||||
from supabase.client import Client
|
||||
|
||||
|
||||
def insert_data_in_table(supabase_client: Client, table_name: str, data: dict):
|
||||
response = supabase_client.table(table_name).insert(data).execute()
|
||||
return response.data
|
||||
|
||||
|
||||
def update_data_in_table(
|
||||
supabase_client: Client,
|
||||
table_name: str,
|
||||
data: dict,
|
||||
identifier: Optional[dict],
|
||||
):
|
||||
response = (
|
||||
supabase_client.table(table_name).update(data).match(identifier).execute()
|
||||
)
|
||||
return response.data
|
||||
|
||||
|
||||
def select_data_in_table(
|
||||
supabase_client: Client,
|
||||
table_name: str,
|
||||
identifier: Optional[dict],
|
||||
):
|
||||
response = supabase_client.table(table_name).select("*").match(identifier).execute()
|
||||
return response.data
|
||||
|
||||
|
||||
def delete_data_in_table(
|
||||
supabase_client: Client,
|
||||
table_name: str,
|
||||
identifier: dict,
|
||||
):
|
||||
response = supabase_client.table(table_name).delete().match(identifier).execute()
|
||||
return response.data
|
Loading…
Reference in New Issue
Block a user