MCPcopy Index your code
hub / github.com/pathwaycom/pathway / read

Function read

python/pathway/io/postgres/__init__.py:284–600  ·  view source on GitHub ↗

**This module is available when using one of the following licenses only:** `Pathway Live Data Framework Scale, Pathway Live Data Framework Enterprise `_. Reads a table from a PostgreSQL database. This connector provides a lightweight alternative to ``pw.io.debezium.read

(
    postgres_settings: dict,
    table_name: str,
    schema: type[Schema],
    *,
    mode: Literal["streaming", "static"] = "streaming",
    is_append_only: bool = False,
    publication_name: str | None = None,
    schema_name: str | None = "public",
    autocommit_duration_ms: int | None = 1500,
    name: str | None = None,
    max_backlog_size: int | None = None,
    debug_data: Any = None,
)

Source from the content-addressed store, hash-verified

282@check_arg_types
283@trace_user_frame
284def read(
285 postgres_settings: dict,
286 table_name: str,
287 schema: type[Schema],
288 *,
289 mode: Literal["streaming", "static"] = "streaming",
290 is_append_only: bool = False,
291 publication_name: str | None = None,
292 schema_name: str | None = "public",
293 autocommit_duration_ms: int | None = 1500,
294 name: str | None = None,
295 max_backlog_size: int | None = None,
296 debug_data: Any = None,
297) -> Table:
298 """
299 **This module is available when using one of the following licenses only:**
300 `Pathway Live Data Framework Scale, Pathway Live Data Framework Enterprise </pricing>`_.
301
302 Reads a table from a PostgreSQL database.
303
304 This connector provides a lightweight alternative to ``pw.io.debezium.read``.
305 It supports two modes: ``"static"`` and ``"streaming"``.
306
307 In ``"static"`` mode, the table is read once and the connector stops afterward.
308
309 In ``"streaming"`` mode, a *temporary* replication slot is created using the
310 ``pgoutput`` logical decoding plugin, which is bundled with PostgreSQL and requires
311 no additional installation. The slot is created with the ``export snapshot`` option,
312 ensuring a consistent initial read. On startup, the connector first performs a
313 snapshot of the table as it existed at the moment the replication slot was created,
314 and then begins consuming the PostgreSQL write-ahead log (WAL), applying incremental
315 changes on top of that snapshot. Because the replication slot is temporary,
316 PostgreSQL will automatically drop it once the connection is closed (i.e., when the
317 program terminates).
318
319 To enable replication, a publication must be created in the database beforehand:
320
321 .. code-block:: sql
322
323 CREATE PUBLICATION {publication_name} FOR TABLE {table_name};
324
325 Args:
326 postgres_settings: Connection parameters for PostgreSQL, provided as a
327 dictionary of key-value pairs. The connection string is assembled by joining
328 all pairs with spaces, each formatted as ``key=value``. Keys must be strings;
329 values of other types are converted via Python&#x27;s ``str()``.
330 The Pathway Live Data Framework injects conservative TCP-keepalive defaults (``keepalives``,
331 ``keepalives_idle=300``, ``keepalives_interval=30``, ``keepalives_count=3``,
332 and ``tcp_user_timeout=300000``) so that an unreachable
333 the Pathway Live Data Framework process is detected by PostgreSQL within minutes rather than
334 the OS-inherited ~2-hour default; any of these can be overridden by
335 passing the same key in ``postgres_settings``.
336 table_name: Name of the PostgreSQL table to read from. Any PostgreSQL
337 identifier is accepted — the connector quotes the name before
338 interpolating it into generated SQL, so hyphens, mixed case, and
339 reserved words round-trip as-is.
340 schema: Pathway Live Data Framework schema describing the table&#x27;s columns and their types.
341 Column names may be any PostgreSQL identifier for the same reason

Callers

nothing calls this directly

Calls 8

_check_entitlementsFunction · 0.90
read_schemaFunction · 0.90
table_from_datasourceFunction · 0.90
_build_tls_settingsFunction · 0.85
copyMethod · 0.45

Tested by

no test coverage detected