Tabledelete¶
flowtask.components.TableDelete
¶
TableDelete
¶
Bases: QSSupport, FlowComponent
TableDelete
Overview
The TableDelete class is a component for deleting rows from a SQL table based on specified primary keys. It uses
Pandas DataFrames to identify rows to delete and performs the deletion using SQLAlchemy and asyncpg.
.. table:: Properties :widths: auto
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| Name | Required | Description |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| flavor | No | The database flavor, defaults to "postgresql". |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| pk | Yes | A list of primary key columns to identify rows for deletion. |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| data | Yes | The data containing rows to be deleted, can be a Pandas DataFrame or other supported format. |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| _engine | No | The SQLAlchemy engine for database connections. |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| tablename | Yes | The name of the table from which rows will be deleted. |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| schema | No | The schema name, defaults to an empty string. |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| _dsn | No | The Data Source Name for the database connection. |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
| multi | No | A flag indicating if multiple DataFrame deletions are supported, defaults to False. |
+------------------+----------+-----------+--------------------------------------------------------------------------------------+
Return
The methods in this class manage the deletion of rows from a SQL table based on primary keys, including initialization,
execution, and result handling. It ensures proper handling of database connections and provides metrics on the deleted rows.
Example:
```yaml
TableDelete:
tablename: totem_heartbeats
flavor: postgres
schema: banco_chile
pk:
- hearbeat_id
```