@tool def sql_engine(query: str) -> str: """ Executes an SQL SELECT query and returns the results. Parameters: query (str): The SQL query string to execute. Only SELECT queries are allowed. Returns: str: A formatted string containing the query results, or an error message if the query fails. """ try: with engine.connect() as con: rows = con.execute(text(query)).fetchall() if not rows: return "No results found." return "\n".join([", ".join(map(str, row)) for row in rows]) except Exception as e: return f"Error: {str(e)}"