Skip to content

API Reference parrot_formdesigner.services.sinks.postgres_table

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.services.sinks.postgres_table

View source

PostgresTableSink — an arbitrary Postgres table owned by a single form.

The reference sink and the only v1 backend with the full capability set (WRITE, READ, LIST, PROVISION, EXTEND). DDL is templated on :class:~parrot_formdesigner.services.submissions. FormSubmissionStorage (_create_table_sql / _alter_table_sql): CREATE TABLE IF NOT EXISTS, additive ADD COLUMN IF NOT EXISTS, and never DROP or RENAME.

Unlike :class:~parrot_formdesigner.services.storage.PostgresFormStorage (which documents that its target schema is assumed to already exist), this sink deliberately provisions its own target — a sanctioned departure bounded by the alias allowlist (:mod:~parrot_formdesigner.services. sink_aliases) and the additive-only rule.

Alias AbstractSubmissionSink

Re-exported from parrot_formdesigner.services.sinks.base.AbstractSubmissionSink.

Alias FieldType

Re-exported from parrot_formdesigner.core.types.FieldType.

Alias FormSchema

Re-exported from parrot_formdesigner.core.schema.FormSchema.

Alias FormSubmission

Re-exported from parrot_formdesigner.services.submissions.FormSubmission.

Class PostgresTableSink

Arbitrary Postgres table owned by a single form.

Parameter Type Default Description
target PostgresTableTarget The validated :class:PostgresTableTarget this sink writes to.
alias_registry SinkAliasRegistry Resolves target.connection to a DSN.
tenant str Tenant scope used to resolve the connection alias.
pool Any | None None An existing asyncpg-compatible pool. When provided, this sink does NOT own it and will not close it. Primarily for tests (a fake pool) or externally managed pools.
min_size int 2 Minimum pool size when this sink creates its own pool.
max_size int 10 Maximum pool size when this sink creates its own pool.
**pool_kwargs Any {} Extra kwargs forwarded to asyncpg.create_pool().

Attributes:

Attribute Type Description
capabilities frozenset[SinkCapability] Full capability set — the reference sink implementation.

Method PostgresTableSink.close

Close the pool if this sink owns it. Idempotent.

close() -> None

Method PostgresTableSink.ensure_target

Create the table if absent, then additively extend it.

ensure_target(form: FormSchema) -> None

Parameter Type Default Description
form FormSchema The form whose columns must all exist on the table.

Raises:

  • SinkTargetMismatchError — If an existing column's type is incompatible with what this form will send.
  • SinkUnavailableError — If the connection cannot be established.

Method PostgresTableSink.write

Insert one row from a flattened payload dict.

write(submission: FormSubmission, payload: Any) -> str

Parameter Type Default Description
submission FormSubmission The submission record being persisted (used only for its submission_id on success).
payload Any The flattened row produced by :func:~parrot_formdesigner.services.sinks.mapper. flatten_submission.

Returns: str — The persisted submission_id.

Raises:

  • SinkUnavailableError — If the write fails (connection or query).

Method PostgresTableSink.read

Fetch a single submission by submission_id.

read(submission_id: str) -> FormSubmission | None

Parameter Type Default Description
submission_id str

Returns: FormSubmission | None

Method PostgresTableSink.list_revisions

Return the full revision chain, oldest first.

list_revisions(root_submission_id: str) -> list[FormSubmission]

Parameter Type Default Description
root_submission_id str

Returns: list[FormSubmission]

Alias PostgresTableTarget

Re-exported from parrot_formdesigner.core.persistence.PostgresTableTarget.

Alias SinkAliasRegistry

Re-exported from parrot_formdesigner.services.sink_aliases.SinkAliasRegistry.

Alias SinkCapability

Re-exported from parrot_formdesigner.core.persistence.SinkCapability.

Alias SinkTargetMismatchError

Re-exported from parrot_formdesigner.services.sinks.base.SinkTargetMismatchError.

Alias SinkUnavailableError

Re-exported from parrot_formdesigner.services.sinks.base.SinkUnavailableError.

Alias column_names_for

Re-exported from parrot_formdesigner.services.sinks.mapper.column_names_for.

Alias field_types_for

Re-exported from parrot_formdesigner.services.sinks.mapper.field_types_for.

Alias qualified_table

Re-exported from parrot_formdesigner.services._identifiers.qualified_table.

Alias validate_identifier

Re-exported from parrot_formdesigner.services._identifiers.validate_identifier.

Alias voice_capable_columns

Re-exported from parrot_formdesigner.services.sinks.mapper.voice_capable_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