MCPcopy Index your code
hub / github.com/dataease/SQLBot / execute_sql_with_db

Function execute_sql_with_db

backend/apps/chat/task/llm.py:1665–1688  ·  view source on GitHub ↗

Execute SQL query using SQLDatabase Args: db: SQLDatabase instance sql: SQL query statement Returns: str: Query results formatted as string

(db: SQLDatabase, sql: str)

Source from the content-addressed store, hash-verified

1663
1664
1665def execute_sql_with_db(db: SQLDatabase, sql: str) -> str:
1666 """Execute SQL query using SQLDatabase
1667
1668 Args:
1669 db: SQLDatabase instance
1670 sql: SQL query statement
1671
1672 Returns:
1673 str: Query results formatted as string
1674 """
1675 try:
1676 # Execute query
1677 result = db.run(sql)
1678
1679 if not result:
1680 return "Query executed successfully but returned no results."
1681
1682 # Format results
1683 return str(result)
1684
1685 except Exception as e:
1686 error_msg = f"SQL execution failed: {str(e)}"
1687 SQLBotLogUtil.exception(error_msg)
1688 raise RuntimeError(error_msg)
1689
1690
1691def request_picture(chat_id: int, record_id: int, chart: dict, data: dict):

Callers

nothing calls this directly

Calls 2

runMethod · 0.80
exceptionMethod · 0.80

Tested by

no test coverage detected