in src/hologres_mcp_server/utils.py [0:0]
def handle_read_resource(resource_name, query, with_headers = False):
"""Handle readResource method."""
config = get_db_config()
try:
with connect_with_retry() as conn:
with conn.cursor() as cursor:
cursor.execute(query)
rows = cursor.fetchall()
headers = [desc[0] for desc in cursor.description]
if with_headers:
return rows, headers
else:
return rows
except Exception as e:
return f"Error executing query: {str(e)}"