run_sql
Run a validated read-only PostgreSQL/PostGIS SELECT query when structured spatial tools cannot express your request; returns attributes and GeoJSON geometry with row limits and timeout safeguards.
Instructions
Run a custom READ-ONLY SQL query (single SELECT, PostgreSQL/PostGIS syntax) when the structured tools do not fit. Validated by a SQL parser, executed in a READ ONLY transaction with a timeout and row cap. Geometry columns are returned as GeoJSON (EPSG:4326). Prefer list_layers/describe_layer first; alias every column.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max rows to return (default 100; server-side cap applies). | |
| query | Yes | One SELECT statement (WITH/UNION allowed). No semicolon-separated batches. | |
| geometry | No | 'auto' (default): full geometry if small, else representative points; 'full'; 'centroid'; 'none' (attributes only). The complete geometry is always kept server-side under result_id for render_map. | auto |