postgres.update.wrds_update_pg

postgres.update.wrds_update_pg(
    table_name,
    schema,
    *,
    wrds_id=None,
    col_types=None,
    sas_schema=None,
    obs=None,
    alt_table_name=None,
    keep=None,
    drop=None,
    rename=None,
    user=None,
    host=None,
    dbname=None,
    port=None,
    force=False,
    create_roles=True,
    wrds_schema=None,
    use_sas=False,
    encoding='utf-8',
    tz='UTC',
)

Materialize a WRDS PostgreSQL table into a local PostgreSQL database.

The destination table is created from scratch based on the SQL SELECT used to extract the data (via DuckDB schema inference), then populated using PostgreSQL binary COPY for performance.

Notes

  • Any existing destination table is dropped.
  • keep/drop use regex matching on source column names.
  • If both drop and keep are provided, drop is applied first.
  • rename maps source column names to output column names. col_types refers to the output names after renaming.
  • Update / fingerprint logic is handled elsewhere (or added later).
  • If create_roles is True, ensures schema owner role (<schema>) and read-only role (<schema>_access) exist, then applies grants.
  • If wrds_schema is provided, it is used as the source WRDS schema while data are still written to destination schema.
  • If use_sas is True, freshness and destination comment metadata are derived from SAS metadata instead of WRDS PostgreSQL comments.
  • sas_schema overrides the SAS-side schema used for metadata lookups when use_sas is True.
  • tz (default "UTC") is used to convert source timestamp without time zone columns via AT TIME ZONE.

Returns

Name Type Description
bool True if an update was performed, False if the destination table was already up to date.