postgres.update.pq_to_pg
postgres.update.pq_to_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',
create_roles=True,
source_comment=None,
)
Write a parquet file from the local repository into PostgreSQL.
Parameters
| 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" |
| create_roles |
bool |
If True, ensure destination schema owner and access roles exist and apply ownership and grants to the loaded table. |
True |
| source_comment |
str |
Comment to store on the destination PostgreSQL table. If omitted, reuse the parquet file’s embedded last_modified metadata. |
None |
Returns
|
bool |
True after the destination table has been created or replaced. |
Examples
>>> pq_to_pg("dsi", "crsp", dbname="research")
>>> pq_to_pg("company", "comp", dst_schema="comp_stage", alt_table_name="company_copy")