ds_provider_postgresql_py_lib.utils¶
File: __init__.py
Region: ds_provider_postgresql_py_lib/utils
Utils Package
This package exports shared helper functions used across provider modules.
Submodules¶
Functions¶
|
Ensure input does not contain duplicate identity values. |
|
Ensure identity columns exist in both input and target table. |
|
Execute a statement with RETURNING and convert rows to dicts. |
|
Build output DataFrame using a stable table-column order. |
|
Convert pandas dtypes Series to a dict mapping column names to SQLAlchemy types. |
|
Safely quote SQL identifiers for dynamic DDL statements. |
Package Contents¶
- ds_provider_postgresql_py_lib.utils.validate_duplicate_identity_rows(content: pandas.DataFrame, identity_columns: collections.abc.Sequence[str]) None[source]¶
Ensure input does not contain duplicate identity values.
- Parameters:
content – Input DataFrame.
identity_columns – Identity columns used for matching.
- Returns:
None
- Raises:
ValidationError – If duplicate identity rows are found.
- ds_provider_postgresql_py_lib.utils.validate_identity_columns(table: sqlalchemy.Table, identity_columns: collections.abc.Sequence[str], content: pandas.DataFrame) None[source]¶
Ensure identity columns exist in both input and target table.
- Parameters:
table – Reflected SQLAlchemy table.
identity_columns – Identity columns used for matching.
content – Input DataFrame.
- Returns:
None
- Raises:
ValidationError – If identity configuration is invalid.
- ds_provider_postgresql_py_lib.utils.execute_returning_rows(conn: sqlalchemy.engine.Connection, stmt: sqlalchemy.sql.Executable) list[dict[str, Any]][source]¶
Execute a statement with RETURNING and convert rows to dicts.
- Parameters:
conn – SQLAlchemy connection.
stmt – SQL statement to execute.
- Returns:
Returned rows as dictionaries.
- Return type:
list[dict[str, Any]]
- ds_provider_postgresql_py_lib.utils.output_from_rows(table: sqlalchemy.Table, rows: list[dict[str, Any]]) pandas.DataFrame[source]¶
Build output DataFrame using a stable table-column order.
- Parameters:
table – Reflected SQLAlchemy table.
rows – Row dictionaries to materialize.
- Returns:
Output DataFrame aligned to table column order.
- Return type:
pd.DataFrame
- ds_provider_postgresql_py_lib.utils.pandas_dtype_to_sqlalchemy(dtypes: pandas.Series) dict[str, Any][source]¶
Convert pandas dtypes Series to a dict mapping column names to SQLAlchemy types.
- Parameters:
dtypes – Pandas dtype series keyed by column name.
- Returns:
SQLAlchemy column types keyed by column name.
- Return type:
dict[str, Any]