# Databases and semantic layer

Read-only database access, NL-to-SQL and the NVIDIA Auto Ontology adapter.

Source: https://glamorous-boar.cloudvent.net/nodes/databases-and-semantic/

---

{/* Generated by scripts/agenticmind/generate-node-docs.mjs from the AgenticMind node registry. Do not edit by hand. */}

Every query is checked by a read-only SQL policy *and* runs on a read-only connection where the engine supports one. See [Databases and NL-to-SQL](/databases/).

| Node | Category | Summary |
|---|---|---|
| [Ask Auto Ontology](#ask-auto-ontology) | Semantic | Answers a question with Auto Ontology's semantic text-to-SQL agent: answer, SQL, rows and steps. |
| [Auto Ontology](#auto-ontology) | Semantic | Connects to an NVIDIA Auto Ontology deployment and checks it is reachable, authorised and ready. |
| [Database Connector](#database-connector) | Semantic | A read-only database connection for the nodes it feeds: SQLite, DuckDB, PostgreSQL (Supabase, Neon, RDS...), MySQL/MariaDB, SQL Server/Azure SQL, Snowflake, Databricks, ClickHouse or BigQuery. Credentials are secret references. |
| [NL-to-SQL](#nl-to-sql) | Semantic | Turns a question into SQL grounded in the schema, validates it read-only, runs it, retries on errors. |
| [Ontology Context](#ontology-context) | Semantic | Looks up the business terms a question mentions, as context for NL-to-SQL or an LLM. |
| [Ontology Term Details](#ontology-term-details) | Semantic | Fetches one business term: its tables, related terms and SQL attributes. |
| [Ontology Term Search](#ontology-term-search) | Semantic | Finds business terms in the Auto Ontology semantic layer by name. |
| [SQL Validator / Executor](#sql-validator-executor) | Semantic | Checks SQL against a read-only policy (one SELECT, known tables, no writes, row cap) and runs it. |
| [Schema Inspector](#schema-inspector) | Semantic | Discovers tables, columns, keys and relationships (and optionally row counts and examples). |
| [Table Profiler](#table-profiler) | Semantic | Summarises a table's data quality and distributions: nulls, distinct values, ranges, top values. |
## Ask Auto Ontology

`agenticmind.semantic.ontology_ask` · version 1.0.0

Answers a question with Auto Ontology's semantic text-to-SQL agent: answer, SQL, rows and steps.

**Typical use.** Asks Auto Ontology's text-to-SQL agent; the result has the same shape as NL-to-SQL, so Chat shows the SQL and rows.

| Input | Type | Required | Description |
|---|---|---|---|
| `ontology` | Ontology | yes |  |
| `question` | String | yes |  |
| `evidence` | String | no |  |

| Output | Type | Description |
|---|---|---|
| `answer` | String |  |
| `sql` | String |  |
| `rows` | JSON |  |
| `result` | JSON | &#123;answer, sql, columns, rows, row_count, steps&#125; |

- **Control branches:** `done`
- **Permissions:** `network`, `credentials`
- **Execution policy:** timeout 1800s, max attempts 1, not idempotent

| Setting | Type | Default | Description |
|---|---|---|---|
| `evidence` | string |  | Optional authoritative facts sent with the question (the input overrides it). |
| `max_rows` | integer | `100` | Rows kept in the result. |
| `timeout_seconds` | number | `300` | A run makes many model calls; tens of seconds is normal. |

## Auto Ontology

`agenticmind.semantic.auto_ontology` · version 1.0.0

Connects to an NVIDIA Auto Ontology deployment and checks it is reachable, authorised and ready.

**Typical use.** Connects to an NVIDIA Auto Ontology deployment and checks it is reachable, the token is valid and the semantic layer is compiled.

*No data inputs.*

| Output | Type | Description |
|---|---|---|
| `ontology` | Ontology |  |
| `status` | JSON | Reachability, auth, compilation and pin |

- **Control branches:** `done`
- **Permissions:** `network`, `credentials`
- **Execution policy:** timeout 30s, max attempts 1, idempotent

| Setting | Type | Default | Description |
|---|---|---|---|
| `base_url` | string | `http://localhost:3000` | The Auto Ontology gateway (its APP_URL; port 3000 in Docker Compose). Not the internal :3001. |
| `api_token` | secret ref |  | Auto Ontology API token secret, e.g. AUTO_ONTOLOGY_API_KEY |
| `require_ready` | boolean | `true` | Fail unless the semantic layer has been compiled (questions need it). |
| `timeout_seconds` | number | `30` | Timeout Seconds |
| `target_db` | string |  | Pin questions to one source database (empty = let Auto Ontology choose). |

## Database Connector

`agenticmind.semantic.database` · version 1.0.0

A read-only database connection for the nodes it feeds: SQLite, DuckDB, PostgreSQL (Supabase, Neon, RDS...), MySQL/MariaDB, SQL Server/Azure SQL, Snowflake, Databricks, ClickHouse or BigQuery. Credentials are secret references.

**Typical use.** A read-only database connection as a handle: SQLite or DuckDB files you upload, or PostgreSQL (Supabase, Neon, RDS), MySQL/MariaDB, SQL Server, Snowflake, Databricks, ClickHouse and BigQuery with secret-referenced credentials. `max_rows` and `timeout_seconds` bound every query.

*No data inputs.*

| Output | Type | Description |
|---|---|---|
| `database` | Database |  |

- **Control branches:** `done`
- **Permissions:** `credentials`
- **Execution policy:** timeout 30s, max attempts 1, idempotent

| Setting | Type | Default | Description |
|---|---|---|---|
| `engine` | `sqlite` · `postgresql` · `mysql` · `sqlserver` · `snowflake` · `databricks` · `duckdb` · `clickhouse` · `bigquery` | `sqlite` | sqlite / duckdb: an uploaded database file. postgresql: also Supabase (Project → Connect → Session pooler string), Neon, Amazon RDS/Aurora, CockroachDB, Redshift. mysql: also MariaDB, PlanetScale, TiDB. sqlserver: also Azure SQL. snowflake, databricks (SQL warehouse), clickhouse, bigquery. Use a read-only login: queries are checked by a read-only SQL policy as well. |
| `file` | array |  | The uploaded database file (.sqlite/.db, or .duckdb). Pick one. |
| `dsn` | secret ref |  | Connection string secret (instead of the fields below), e.g. postgresql://user:pass@host:5432/db |
| `host` | string |  | Server host, e.g. db.example.com. Databricks: the workspace host (dbc-1234.cloud.databricks.com). |
| `port` | integer |  | Empty: the engine's default port. |
| `database` | string |  | Database name. BigQuery: the dataset. DuckDB: the MotherDuck database. |
| `user` | string |  | User |
| `password` | secret ref |  | Password secret (Snowflake: a password or programmatic access token) |
| `ssl` | `require` · `prefer` · `disable` | `require` | Encrypt the connection (cloud databases require it). |
| `account` | string |  | Snowflake account identifier, e.g. myorg-myaccount. |
| `warehouse` | string |  | Snowflake: the virtual warehouse. Databricks: the SQL warehouse ID or its HTTP path. |
| `role` | string |  | Role |
| `private_key` | secret ref |  | Key-pair authentication: secret holding the PEM private key (instead of a password) |
| `catalog` | string |  | Unity Catalog catalog. |
| `default_schema` | string |  | Default schema. |
| `token` | secret ref |  | Databricks: personal access / OAuth token secret. DuckDB: MotherDuck token secret. |
| `project` | string |  | Google Cloud project (default: the service account's project). |
| `service_account` | secret ref |  | Secret holding the service-account JSON key (role: BigQuery Data Viewer + Job User) |
| `location` | string |  | Dataset location, e.g. US or EU. |
| `schemas` | array |  | Limit queries to these schemas or schema.table names (empty = everything readable). |
| `max_rows` | integer | `500` | Upper bound on rows any query returns. |
| `timeout_seconds` | number | `15` | Upper bound on any query's duration. |

## NL-to-SQL

`agenticmind.semantic.nl_to_sql` · version 1.0.0

Turns a question into SQL grounded in the schema, validates it read-only, runs it, retries on errors.

**Typical use.** Turns a plain-language question into SQL grounded in the schema (and optional business context), validates it, runs it and retries with the error shown to the model. Can answer `answerable=false` instead of guessing.

| Input | Type | Required | Description |
|---|---|---|---|
| `question` | String | yes |  |
| `database` | Database | yes |  |
| `schema` | String | no | Schema text (default: inspect) |
| `context` | String | no | Business definitions, metrics |

| Output | Type | Description |
|---|---|---|
| `sql` | String |  |
| `rows` | JSON |  |
| `result` | JSON | &#123;answer, sql, rows, columns, row_count, attempts&#125; |

- **Control branches:** `done`
- **Permissions:** `network`, `filesystem`, `database`, `credentials`, `artifacts`
- **Execution policy:** timeout 300s, max attempts 1, idempotent

| Setting | Type | Default | Description |
|---|---|---|---|
| `provider` | `openrouter` · `openai` · `anthropic` · `gemini` · `azure_openai` · `bedrock` · `mistral` · `groq` · `deepseek` · `together` · `xai` · `huggingface` · `ollama` · `openai_compatible` · `mock` | `openrouter` | Provider |
| `model` | string | `google/gemini-3.8-flash` | Model |
| `api_key` | secret ref |  | API key secret, e.g. OPENROUTER_API_KEY |
| `base_url` | string |  | Base Url |
| `instructions` | string | see below | Instructions |
| `attempts` | integer | `3` | Tries: errors are shown to the model to fix. |
| `execute` | boolean | `true` | Run the validated SQL and return rows. |
| `max_rows` | integer | `200` | Max Rows |
| `temperature` | number | `0` | Temperature |
| `max_tokens` | integer | `4000` | Max Tokens |

<CodeBlock language="text" filename="Default instructions">

```
Prefer simple, correct SQL. Use only the tables and columns listed. Qualify ambiguous columns. For top-N questions, include rows tied at the cut-off (e.g. with a window function) or say that there are ties.
```

</CodeBlock>

## Ontology Context

`agenticmind.semantic.ontology_context` · version 1.0.0

Looks up the business terms a question mentions, as context for NL-to-SQL or an LLM.

**Typical use.** Finds the business terms a question mentions and returns them as text context, for example to ground NL-to-SQL.

| Input | Type | Required | Description |
|---|---|---|---|
| `ontology` | Ontology | yes |  |
| `question` | String | yes |  |

| Output | Type | Description |
|---|---|---|
| `context` | String | Definitions, tables and measures |
| `terms` | JSON |  |

- **Control branches:** `done`
- **Permissions:** `network`, `credentials`
- **Execution policy:** timeout 30s, max attempts 1, idempotent

| Setting | Type | Default | Description |
|---|---|---|---|
| `max_terms` | integer | `5` | Terms to include (best matches first). |

## Ontology Term Details

`agenticmind.semantic.ontology_term` · version 1.0.0

Fetches one business term: its tables, related terms and SQL attributes.

**Typical use.** Fetches one business term with its tables, related terms and SQL measures.

| Input | Type | Required | Description |
|---|---|---|---|
| `ontology` | Ontology | yes |  |
| `term` | String | no |  |

| Output | Type | Description |
|---|---|---|
| `term` | JSON |  |
| `text` | String |  |

- **Control branches:** `done`
- **Permissions:** `network`, `credentials`
- **Execution policy:** timeout 30s, max attempts 1, idempotent

| Setting | Type | Default | Description |
|---|---|---|---|
| `term` | string |  | Term id or exact name; the input overrides it. |
| `sql_attributes` | boolean | `true` | Include the term's SQL attributes (measures). |

## Ontology Term Search

`agenticmind.semantic.ontology_terms` · version 1.0.0

Finds business terms in the Auto Ontology semantic layer by name.

**Typical use.** Searches business terms in the Auto Ontology semantic layer by name.

| Input | Type | Required | Description |
|---|---|---|---|
| `ontology` | Ontology | yes |  |
| `query` | String | no |  |

| Output | Type | Description |
|---|---|---|
| `terms` | JSON | [&#123;id, name, synonyms, description, …&#125;] |
| `text` | String |  |
| `total` | Number |  |

- **Control branches:** `done`
- **Permissions:** `network`, `credentials`
- **Execution policy:** timeout 30s, max attempts 1, idempotent

| Setting | Type | Default | Description |
|---|---|---|---|
| `query` | string |  | Name filter (case-insensitive substring); the input overrides it. |
| `limit` | integer | `25` | Limit |

## SQL Validator / Executor

`agenticmind.semantic.sql_executor` · version 1.0.0

Checks SQL against a read-only policy (one SELECT, known tables, no writes, row cap) and runs it.

**Typical use.** Checks SQL against the read-only policy (exactly one SELECT, known and allowed tables, no denied functions, row cap) and runs it, or only validates it.

| Input | Type | Required | Description |
|---|---|---|---|
| `database` | Database | yes |  |
| `sql` | String | yes |  |

| Output | Type | Description |
|---|---|---|
| `rows` | JSON | List of row objects |
| `columns` | JSON |  |
| `result` | JSON | &#123;sql (as run), tables, row_count, truncated, notes&#125; |

- **Control branches:** `done`
- **Permissions:** `filesystem`, `database`, `credentials`, `artifacts`
- **Execution policy:** timeout 120s, max attempts 1, idempotent

| Setting | Type | Default | Description |
|---|---|---|---|
| `mode` | `execute` · `validate` | `execute` | validate: check against the policy only. execute: check, then run read-only. |
| `allowed_tables` | array |  | Extra allow-list for this node (empty = every table the connection allows). |
| `max_rows` | integer |  | Lower the connection's row cap. |

## Schema Inspector

`agenticmind.semantic.schema_inspector` · version 1.0.0

Discovers tables, columns, keys and relationships (and optionally row counts and examples).

**Typical use.** Discovers tables, columns, keys, foreign keys, row counts and example rows, plus a compact text form to put in prompts.

| Input | Type | Required | Description |
|---|---|---|---|
| `database` | Database | yes |  |

| Output | Type | Description |
|---|---|---|
| `schema` | JSON | &#123;engine, tables: [&#123;name, columns, foreign_keys, …&#125;]&#125; |
| `text` | String | Compact schema description for prompts |
| `table_count` | Number |  |

- **Control branches:** `done`
- **Permissions:** `filesystem`, `database`, `credentials`, `artifacts`
- **Execution policy:** timeout 120s, max attempts 2, idempotent

| Setting | Type | Default | Description |
|---|---|---|---|
| `tables` | array |  | Only these tables (glob patterns; empty = all). |
| `row_counts` | boolean | `true` | Count rows per table. |
| `sample_rows` | integer | `0` | Example rows per table (0 = none). |
| `max_tables` | integer | `200` | Max Tables |

## Table Profiler

`agenticmind.semantic.table_profiler` · version 1.0.0

Summarises a table's data quality and distributions: nulls, distinct values, ranges, top values.

**Typical use.** Data-quality profile of one table: null rate, distinct values, ranges or text lengths, and top values over a bounded scan.

| Input | Type | Required | Description |
|---|---|---|---|
| `database` | Database | yes |  |

| Output | Type | Description |
|---|---|---|
| `profile` | JSON |  |
| `text` | String | Readable summary |

- **Control branches:** `done`
- **Permissions:** `filesystem`, `database`, `credentials`, `artifacts`
- **Execution policy:** timeout 300s, max attempts 1, idempotent

| Setting | Type | Default | Description |
|---|---|---|---|
| `table` | string |  | Table to profile (name or schema.name). |
| `columns` | array |  | Only these columns (empty = all). |
| `top_values` | integer | `5` | Most frequent values per column. |
| `max_rows_scanned` | integer | `100000` | Profile at most this many rows. |
