Search CKAN DataStore with SQL
ckan_datastore_search_sqlRun SQL SELECT queries on CKAN DataStore resources to filter, aggregate, and retrieve public open data.
Instructions
Run SQL queries on a CKAN DataStore resource.
This endpoint is only available on CKAN portals with DataStore enabled and SQL access exposed.
Args:
server_url (string): Base URL of CKAN server
sql (string): SQL query (e.g., SELECT * FROM "resource_id" LIMIT 10)
response_format ('markdown' | 'json'): Output format
Returns: SQL query results from DataStore
Examples:
{ server_url: "...", sql: "SELECT * FROM "abc-123" LIMIT 10" }
{ server_url: "...", sql: "SELECT COUNT(*) AS total FROM "abc-123"" }
Typical workflow: ckan_package_show (get resource_id) → ckan_datastore_search_sql (run SQL on it)
Security note: SQL queries are forwarded directly to the CKAN DataStore API. The CKAN server enforces its own access controls and read-only permissions. No local database is exposed. Queries are limited to public DataStore resources on the target portal.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | SQL SELECT query; resource_id is the table name, must be double-quoted (e.g., SELECT * FROM "abc-123" LIMIT 10) | |
| server_url | Yes | Base URL of the CKAN server (e.g., https://dati.gov.it/opendata) | |
| response_format | No | Output format: 'markdown' for human-readable or 'json' for machine-readable | markdown |