Spaces:
Sleeping
Sleeping
File size: 631 Bytes
eec3758 | 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 | from supabase_db import DatabaseConnection
def execute_sql_query(query: str):
try:
db_instance = DatabaseConnection()
db_instance.connect()
conn = db_instance.get_connection()
if conn:
with conn.cursor() as cur:
cur.execute(query)
results = cur.fetchall()
db_instance.release_connection(conn) # Release the connection back to the pool
return results
else:
raise Exception("Database connection error")
except Exception as e:
return f"An error occurred while querying the database: {e}"
|