loom.core.sql.config¶
Typed configuration for the backend-agnostic sql: section.
Parsed via ctx.section(ConfigKey.SQL, SqlConfig). Validation is fail-fast:
invalid values abort the parse and surface as
ConfigError through the config loader.
Functions
|
|
|
|
|
|
|
|
|
|
|
Report whether an allowlist would be left for the caller to pick from. |
Classes
|
Root of the |
|
Named SQL connection with role policy, limits and driver tuning. |
|
Opt-in REST endpoint settings for a SQL connection. |
- loom.core.sql.config.roles_need_identity_binding(allowed_roles, *, mechanism_binds_roles)[source]¶
Report whether an allowlist would be left for the caller to pick from.
A connection allowing several roles only makes sense when something binds a caller to a subset of them. Without that binding the allowlist stops being a ceiling and becomes a menu, so every layer that can mount such an endpoint refuses to. The predicate lives here, next to the config it judges; each layer phrases its own error.
- class loom.core.sql.config.SqlEndpointConfig(*, enabled=False, auth=None, path=None, include_in_schema=False)[source]¶
Bases:
LoomFrozenStructOpt-in REST endpoint settings for a SQL connection.
- Parameters:
- enabled¶
Whether to mount the generic
POST /sql/{name}endpoint. Defaults toFalse(double opt-in).- Type:
- auth¶
Mandatory when
enabled:"identity"(the framework authenticates the caller with the configured mechanism and binds roles to their verified identity) or"external"(explicit acknowledgement that the operator provides authentication, with no identity the framework can read)."jwt"is a deprecated alias of"identity".- Type:
Literal[‘identity’, ‘jwt’, ‘external’] | None
- class loom.core.sql.config.SqlConnectionConfig(*, backend, url, username=None, password=None, allowed_roles=(), default_role=None, readonly=True, default_limit=1000, max_limit=10000, max_execution_time=30, max_sql_bytes=262144, connect_timeout=10, send_receive_timeout=60, executor_threads=None, pool_size=None, settings=<factory>, sql_endpoint=<factory>)[source]¶
Bases:
LoomFrozenStructNamed SQL connection with role policy, limits and driver tuning.
- backend¶
Backend identifier. Only
"clickhouse"is supported; any other value fails the parse.- Type:
Literal[‘clickhouse’]
- username¶
Driver username, handed to the driver as an explicit argument. Takes precedence over any credential embedded in
url.- Type:
str | None
- password¶
Driver password, handed to the driver as an explicit argument. Unlike a DSN credential it is never URL-parsed, so any character is safe (a
#inside a DSN password truncates it as a fragment delimiter and the driver does not unescape quoted ones), and it never appears inrepror in dumps ofurl.- Type:
str | None
- allowed_roles¶
Ceiling of roles this connection may ever apply — the last barrier, not a per-caller permission. Empty means every caller-provided role is rejected (fail-closed). A mounted endpoint with a non-empty allowlist requires the
sql_endpoint.authmode that binds roles to a verified identity.
- default_role¶
Role applied when the request carries none. Without it, a request without role is refused. Never a fallback for a request whose roles are bound to verified claims.
- Type:
str | None
- settings¶
Extra backend settings handed to the executor at construction. They can never override the policy.
- sql_endpoint¶
Optional REST endpoint settings for this connection.
- Raises:
ValueError – On invalid role format,
default_limitabovemax_limit, or an enabled endpoint without role/auth, including a non-empty allowlist under an auth mode that carries no verified identity. Surfaced asConfigErrorwhen parsed through the config loader.- Parameters:
backend (Literal['clickhouse'])
url (str)
username (str | None)
password (str | None)
default_role (str | None)
readonly (bool)
default_limit (int)
max_limit (int)
max_execution_time (int)
max_sql_bytes (int)
connect_timeout (int)
send_receive_timeout (int)
executor_threads (int | None)
pool_size (int | None)
sql_endpoint (SqlEndpointConfig)
- class loom.core.sql.config.SqlConfig(*, connections)[source]¶
Bases:
LoomFrozenStructRoot of the
sql:config section.- Parameters:
connections (dict[str, SqlConnectionConfig])
- connections¶
Named SQL connections available to the query service.