Spaces:
Sleeping
Sleeping
| 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}" | |