execute_query
Retrieve and analyze data from SAP Datasphere tables using read-only SQL queries. Filter, join, and aggregate results with a default limit of 100 rows.
Instructions
Execute read-only SQL queries against SAP Datasphere tables to retrieve and analyze data.
IMPORTANT: This is a HIGH-RISK tool that requires user consent before execution.
Use this tool when:
User explicitly requests data retrieval (e.g., "Show me customers from USA")
Need to perform data analysis with aggregations
Joining multiple tables for insights
Filtering and sorting data
Capabilities:
SELECT queries with full SQL syntax (WHERE, JOIN, GROUP BY, ORDER BY, LIMIT)
Read-only access - NO write operations allowed
Results limited to 100 rows by default (configurable via limit parameter)
Automatic query sanitization and injection prevention
Security & Restrictions:
Only SELECT statements allowed
Blocked operations: INSERT, UPDATE, DELETE, DROP, CREATE, ALTER, etc.
No SQL comments allowed (security risk)
Queries sanitized to prevent injection attacks
User consent required before execution (high-risk operation)
Query best practices:
Always specify a LIMIT to control result size
Use WHERE clauses to filter data efficiently
Check table schema first with get_table_schema()
Use qualified table names when joining
Example queries:
"SELECT * FROM CUSTOMER_DATA WHERE country = 'USA' LIMIT 10"
"SELECT customer_id, SUM(amount) as total FROM SALES_ORDERS GROUP BY customer_id ORDER BY total DESC LIMIT 20"
"SELECT c.customer_name, o.order_date, o.amount FROM CUSTOMER_DATA c JOIN SALES_ORDERS o ON c.customer_id = o.customer_id WHERE o.status = 'COMPLETED' LIMIT 50"
Error handling:
Invalid SQL syntax: Returns syntax error with guidance
Forbidden operations: Blocked with explanation
Missing tables: Suggests using search_tables() to find correct name
Permission denied: Explains consent requirement
Note: This tool uses mock data in development. Real query execution requires OAuth authentication.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| space_id | Yes | The Datasphere space ID where tables exist (e.g., 'SALES_ANALYTICS', 'FINANCE_DWH'). Must be uppercase. | |
| sql_query | Yes | The SELECT query to execute. Must start with SELECT. Examples: 'SELECT * FROM CUSTOMER_DATA LIMIT 10', 'SELECT customer_id, COUNT(*) FROM SALES_ORDERS GROUP BY customer_id' | |
| limit | No | Maximum number of rows to return. Default: 100. Range: 1-1000. Use smaller limits for faster responses. |