Skip to main content

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:

  • USUARIO
  • PASSWORD
  • HOSTNAME
  • PORT
  • DATABASE

🧹 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 cargar
  • output_table: schema.table
  • uid_cols: columnas para generar ID único
  • uid_need: columna ya existente como ID
  • truncate: si True, borra la tabla antes

Comportamiento:

  • 🔁 Carga incremental (default):

    • Genera unique_id
    • Convierte datos a polars
    • Realiza anti-join para evitar duplicados
  • 🧨 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

loaddata-1.1.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

loaddata-1.1.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file loaddata-1.1.1.tar.gz.

File metadata

  • Download URL: loaddata-1.1.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for loaddata-1.1.1.tar.gz
Algorithm Hash digest
SHA256 26576816309ce8cf75c2d86d2199143648efa7e912130a7f08dc856a6e8598dc
MD5 adc3c6047f66dda432e5903a77b8d8be
BLAKE2b-256 d114793aa77a1e3c143b1c3c73f249b14133d378511ed2527664eeae2f871201

See more details on using hashes here.

File details

Details for the file loaddata-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: loaddata-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for loaddata-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3af1aaaebdfe66b85a3814ba6f19cf27ec68b1ff8f77efabe39628ac6c89026a
MD5 3c70317cdc6d125b7df57f0e4b73cfec
BLAKE2b-256 4bade9021a3ce77a9e21a2ac2572425e4f5692ad3efd13d8a7bcac43e9bdbfb9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page