Incremental load to database
Project description
📦 LoadData & DataContractValidator
Este módulo proporciona utilidades para:
- Carga de datos en PostgreSQL
- Generación de identificadores únicos
- Validación de contratos de datos
- Manejo de fechas
🧱 Clase: LoadData
Clase principal para gestionar la carga de datos en base de datos PostgreSQL.
🔌 enginepsql()
Crea y devuelve un engine de conexión a PostgreSQL usando variables de entorno:
USUARIOPASSWORDHOSTNAMEPORTDATABASE
🧹 truncate_table(schema, table)
Trunca una tabla sin eliminar su estructura:
- Desactiva triggers (FKs)
- Ejecuta
TRUNCATE - Reactiva triggers
🆔 unique_id_()
Genera un identificador único (unique_id) para cada fila del DataFrame:
- Usa columnas definidas en
uid_cols - Limpia strings (lowercase, sin acentos ni caracteres especiales)
- Genera hash SHA256 → entero int64
📥 load_all_data(...)
Carga datos en PostgreSQL.
Parámetros:
input_table: DataFrame a cargaroutput_table:schema.tableuid_cols: columnas para generar ID únicouid_need: columna ya existente como IDtruncate: siTrue, borra la tabla antes
Comportamiento:
-
🔁 Carga incremental (default):
- Genera
unique_id - Convierte datos a
polars - Realiza
anti-joinpara evitar duplicados
- Genera
-
🧨 Carga completa (
truncate=True):- Trunca tabla
- Inserta todos los datos
-
🆕 Si la tabla no existe:
- La crea automáticamente
📊 reportar_datos_aniadidos()
Imprime en consola el número de filas insertadas:
{"datos_aniadidos": X}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file loaddata-1.1.4.tar.gz.
File metadata
- Download URL: loaddata-1.1.4.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3c99dafad021c5ef24956f1b604a47d6f6b73ca786f6926d56969ed8a0c152a
|
|
| MD5 |
19b653ce5e11392349f0610ff3808899
|
|
| BLAKE2b-256 |
162e9a5f6de3154343c985315018d577bddcf4699f89e73d439e1d3d4e22864d
|
File details
Details for the file loaddata-1.1.4-py3-none-any.whl.
File metadata
- Download URL: loaddata-1.1.4-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
286609b1cbb372519f53c1a41550f08da94243246d9f3cf49bb12b9ed3c680a8
|
|
| MD5 |
94b1e9033a7df3484bc5f54398128360
|
|
| BLAKE2b-256 |
810f8edaed728be724385e9c36f3eabd176c09a35699faf00a14ae25fca69281
|