Skip to main content
This app reads one PostgreSQL table with a primary key of one to eight bigint, text, or varchar columns. It publishes the newest observation per key and the next position in the same commit at the mount’s data label. For changes from a dedicated PostgreSQL slot, use logical replication. The same app has profiles for MySQL, MariaDB, SQL Server, Oracle, BigQuery, Snowflake, Redshift, Databricks SQL, ClickHouse, Exasol, Netezza, SAP ASE and Vertica. The mount’s clock starts a due pass at its next ten-second turn. Each page progresses through a continuation of the SQL receiver’s task.

Mount and bind

The SQL app is a mountable app: sql({ data, provider, writer }) returns the app to place at a path of your tree. Bind the SQL receiver (SqlReceiver) with one of the package’s binders, declare its credential with secret(), and place all three in the same tree.
app.ts
Every relation and writer binder takes the endpoint, the credential and the label as its last, optional argument. The mount’s records, positions and task results live under data, and the receiver answers under the same label. The host reserves clock and send capacity from the label’s declared quotas. The mount declares its operator role, which clears data. The operator runs the mount’s clocks and is the only role its functions allow. Set the credential, grant the role and start the source:
sql.operator is granted from code: ctx.grant(sql.operator, { to, under }) in one of your mutations (Grants). Use a read-only account limited to the chosen table. Pass the revision from sql.source.health to poll, pause and resume.
The driver requires TLS and checks the endpoint against platform trust. Use a UTF-8 database and list the complete primary key in declaration order. Pages compare the full tuple, using numeric order for bigint and byte order for text. Record keys are JSON arrays of strings, such as ["EMEA","9007199254740993"], and may use up to 512 encoded bytes. Payloads are PostgreSQL row JSON text. Each bounded read checks relation and key identity in its read-only snapshot. A page carries up to 32 rows and uses at most 48 KiB after encoding the result for the task result. The app can request 128 pages per polling turn and resumes after the last published tuple when it yields. A single row that cannot fit blocks progress at that key. A retained relation identity change stops the source and requires an explicit reset at the health revision and gap instant. Each page observes its own PostgreSQL snapshot. Concurrent writes can affect which keys a traversal sees. Later traversals refresh observed keys and keep keys that disappear.

Read consistency by mode

Every read mode retains its receiver reply and publishes records and positions at the mount’s data label. Each accepted page advances the position in the same commit as its changes.

Parameterized SQL writes

Pass a writer receiver as writer, bound at the same data label. Without writer the mount has no writes subtree. The operator calls sql.writes.dml and sql.writes.get. The writer uses the installed dialect and a sealed credential with a declared relation, ordered key and writable projection.
Socket writer credentials take username, password, database and relation. Warehouse writer credentials take token, relation and settings. Use the settings from the matching reader guide. Authorize the account for the declared table, its metadata, required locks and DML. Use a principal restricted to the intended table and operation permissions.
The relation accepts one to eight key columns and up to sixteen distinct writable columns. Supported kinds are text and bigint. Supply the key tuple in declaration order, using the same ordered key coordinates as the PostgreSQL read profile. Bigints are canonical signed decimal strings. Text preserves its UTF-8 contents, and key equality follows the declared provider column’s comparison semantics. The encoded key is bounded to 512 bytes, and supplied non-key values total at most 16 KiB.
Insert supplies the entire key and any projected values. Omitted insert fields use provider defaults. Update must name at least one projected field. Delete supplies an empty values object. Explicit null means SQL NULL for a projected column. Use a new command key for a different request: the same key with other inputs refuses KeyReused, and an invalid command refuses InvalidCommand. The app submits bound values and fixed DML once per command key, with one send per task. PostgreSQL, MySQL, MariaDB and SQL Server require the complete provider primary key. MySQL and MariaDB require InnoDB. Redshift serializes the guarded statement under a table lock. BigQuery and Snowflake check the declared key in the statement snapshot. Coordinate independent inserts at those warehouses if uniqueness must hold across concurrent writers. writes.get({ key }) reports committed with the provider’s direct affected-row count, 0 or 1. A refused task is reported as refused with the refusal value in refusal. Socket writers require a COMMIT acknowledgement. The warehouse writers require a completed statement or job and its DML count. A zero count can reflect a missing key, a guard refusing a duplicate, or the provider’s changed-row semantics. Triggers, cascades, later writes and replica visibility have their own outcomes. A lost or ambiguous acknowledgement settles the task Unknown. Writes leave the read cursor intact.