query¶
- mcp_ohmy_sql.sa.query.format_result(result: CursorResult | Result) str[source]¶
Format SQL query result into a Markdown table.
Note
Markdown tables are the optimal format for presenting SQL query results to LLMs, offering the best combination of token efficiency, comprehension, and maintainability.
- Token Efficiency: Uses 24% fewer tokens than JSON, reducing API costs
and fitting more data within context limits
- Natural LLM Comprehension: Aligns with LLM training data patterns,
enabling better understanding compared to nested JSON/XML structures
- Balanced Readability: Maintains both machine parsability and human readability
for seamless debugging and maintenance
- mcp_ohmy_sql.sa.query.ensure_valid_select_query(query: str)[source]¶
Ensure the query is a valid SELECT statement.