Skip to content

API Reference parrot.semantic.accounting.runtime.database

github-actions[bot] edited this page Dec 2, 2026 · 1 revision

parrot.semantic.accounting.runtime.database

View source

Database target for accounting queries through the shipped semantic Executor (FEAT-713 M6).

Alias AccountingExecutionError

Re-exported from parrot.semantic.accounting.errors.AccountingExecutionError.

Alias AccountingModel

Re-exported from parrot.semantic.accounting.models.AccountingModel.

Attribute CHART_SUBJECT_DIGEST

Alias CompiledMetricQuery

Re-exported from parrot.semantic.accounting.models.CompiledMetricQuery.

Class DatabaseRuntime

Wraps compiled SQL in a GovernedQuery and runs it unchanged through Executor.run_with_columns.

Parameter Type Default Description
executor Executor The semantic-layer executor (toolkit + connection resolver).
result_limit int 10000 Maximum number of result rows; more ⇒ AccountingExecutionError.

Method DatabaseRuntime.dialect_for

The sqlglot dialect of the model's journal driver.

dialect_for(model: AccountingModel) -> str

Parameter Type Default Description
model AccountingModel Model whose journal source is a database table.

Returns: str — executor.toolkit.get_source(driver).sqlglot_dialect.

Raises:

  • AccountingExecutionError — The source is a dataframe, the driver is unknown, or it has no SQL dialect.

Method DatabaseRuntime.execute

Run the compiled SQL unchanged through Executor.run_with_columns and evaluate exactly.

execute(compiled: CompiledMetricQuery, model: AccountingModel, *, subject_digest: str) -> RuntimeResult

Parameter Type Default Description
compiled CompiledMetricQuery The compiled query; compiled.sql is sent byte-for-byte (no LIMIT is added).
model AccountingModel The model whose journal source is a database table.
subject_digest str Digest of the requesting subject, supplied by the caller.

Returns: RuntimeResult — Evaluated rows with exact Decimal amounts.

Raises:

  • AccountingExecutionError — Dataframe source, execution failure, or a truncated result.

Method DatabaseRuntime.fetch_chart_rows

SELECT DISTINCT <columns> FROM <table> of the account master through the executor.

Identifiers are built as quoted sqlglot nodes; nothing is interpolated into SQL text.

fetch_chart_rows(*, connection: str, driver: str, table: str, columns: Sequence[str]) -> list[dict]

Parameter Type Default Description
connection str Named connection for the ConnectionResolver.
driver str DatabaseQueryToolkit driver name.
table str [catalog.][db.]table of the account master.
columns Sequence[str] Columns to read (feeds snapshot_from_rows).

Returns: list[dict] — The distinct rows.

Raises:

  • AccountingExecutionError — No columns, invalid table, execution failure or truncation.

Method DatabaseRuntime.fetch_columns

Journal column types through source.get_metadata(credentials, [table]).

fetch_columns(*, connection: str, driver: str, table: str) -> dict[str, str]

Parameter Type Default Description
connection str Named connection for the ConnectionResolver.
driver str DatabaseQueryToolkit driver name.
table str [db.]table of the journal.

Returns: dict[str, str] — {column name: data_type} in metadata order.

Raises:

  • AccountingExecutionError — Unknown driver, unresolved credentials, metadata failure or missing table.

Alias Executor

Re-exported from parrot.semantic.execution.Executor.

Alias GovernedQuery

Re-exported from parrot.semantic.models.GovernedQuery.

Alias RuntimeResult

Re-exported from parrot.semantic.accounting.models.RuntimeResult.

Alias SemanticExecutionError

Re-exported from parrot.semantic.errors.SemanticExecutionError.

Alias evaluate_rows

Re-exported from parrot.semantic.accounting.evaluation.evaluate_rows.

Alias output_columns

Re-exported from parrot.semantic.accounting.runtime.duckdb.output_columns.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally