postgres.update.pq_update_pg

postgres.update.pq_update_pg(
    table_name,
    schema,
    *,
    data_dir=None,
    user=None,
    host=None,
    dbname=None,
    database=None,
    port=None,
    dst_schema=None,
    alt_table_name=None,
    engine='duckdb',
    force=False,
    create_roles=True,
)

Materialize a parquet file into PostgreSQL when the parquet source is newer.

Parameters

Name Type Description Default
table_name str Basename of the source parquet file. required
schema str Name of the source parquet schema directory. required
data_dir str Root directory of the parquet data repository. If omitted, defaults to DATA_DIR or the current working directory. None
user str Destination PostgreSQL user role. None
host str Destination PostgreSQL host name. None
dbname str Destination PostgreSQL database name. None
database str Alias for dbname. None
port int Destination PostgreSQL port. None
dst_schema str Destination PostgreSQL schema. If omitted, defaults to schema. None
alt_table_name str Destination PostgreSQL table name. If omitted, defaults to table_name. None
engine (duckdb, adbc) Engine used to load the parquet file into PostgreSQL. "duckdb"
force bool If True, import the parquet file even when the source metadata are missing or the destination does not appear stale. False
create_roles bool If True, ensure destination schema owner and access roles exist and apply ownership and grants to the loaded table. True

Returns

Name Type Description
bool True if the parquet file was imported. False if the destination was already current or the source metadata were insufficient and force was not requested.

Examples

>>> pq_update_pg("dsi", "crsp", dbname="research")
>>> pq_update_pg("company", "comp", dbname="research", force=True)