query
Execute raw SurrealQL queries to perform complex database operations including SELECT statements with joins, schema definitions, transactions, and graph traversals directly on SurrealDB.
Instructions
Execute a raw SurrealQL query against the connected SurrealDB database.
This tool allows you to run any valid SurrealQL query directly. Use this for complex queries that don't fit the other tool patterns, such as:
Complex SELECT queries with JOINs, GROUP BY, or aggregations
Custom DEFINE statements for schemas
Transaction blocks with BEGIN/COMMIT
Graph traversal queries
Args: query_string: The complete SurrealQL query to execute. Examples: - "SELECT * FROM user WHERE age > 18" - "SELECT *, ->purchase->product FROM user:john" - "BEGIN; CREATE user:alice SET name = 'Alice'; CREATE user:bob SET name = 'Bob'; COMMIT;"
Returns: A dictionary containing: - success: Boolean indicating if the query executed successfully - data: The query results (format depends on the query) - error: Error message if the query failed (only present on failure)
Example: >>> await query("SELECT name, age FROM user WHERE active = true ORDER BY created DESC LIMIT 10") {"success": true, "data": [{"name": "Alice", "age": 30}, {"name": "Bob", "age": 25}]}
Input Schema
Name | Required | Description | Default |
---|---|---|---|
query_string | Yes |