Tableoutput¶
flowtask.components.TableOutput
¶
TableOutput
¶
TableOutput
¶
Bases: FlowComponent, CredentialsInterface
TableOutput
Overview
The TableOutput class is a component for copying data to SQL tables using Pandas and SQLAlchemy features. It supports
various SQL flavors such as PostgreSQL, MySQL, and SQLAlchemy. The class handles data type detection, data transformation,
and the INSERT-UPDATE mechanism.
.. table:: Properties :widths: auto
+------------------+----------+--------------------------------------------------------------------------------------------------+
| Name | Required | Description |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| _pk | No | A list of primary keys for the table. |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| _fk | No | The foreign key for the table. |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| data | Yes | The data to be copied to the table. |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| _engine | Yes | The database engine used for the SQL operations. |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| _columns | No | A list of columns in the table. |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| _schema | No | The schema of the table. |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| _constraint | No | A list of constraints for the table. |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| _dsn | Yes | The data source name (DSN) for the database connection. |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| flavor | Yes | The SQL flavor for the database, defaults to "postgresql". |
+------------------+----------+--------------------------------------------------------------------------------------------------+
| multi | No | A flag indicating if multiple DataFrame transformations are supported, defaults to False. |
+------------------+----------+--------------------------------------------------------------------------------------------------+
Returns:
DataFrame: The data that was copied to the table.
Example:
```yaml
TableOutput:
tablename: business_hours
flavor: postgres
schema: banco_chile
pk:
- store_id
- weekday
if_exists: append
```