Introduction
Exporting data from a database requires three modelling objects:
- Table: The location(s) in PhixFlow which holds the data required for export.
- Data Exporter: sends data to the datasource using a SQL command.
- Datasource: Provides the connection to the database.
Solution
1. Table
- Hover over the Table and from the popup menu click Database Exporter.
- The Data Exporter is created and a property editor opens on the right. Alternatively a Data Exporter can be dragged onto the canvas from the Toobar.
2. Database Collector
- In the property editor complete the details:
- Name, Provide a name that is indicative of the data being exported.
- Enabled, Tick this option.
- Datasource, This option specifies where the data will be written. You can use an existing Datasource or see step 3 below for creating a new one.
- Statement Expression, is the SQL statement that will be used to insert or update the data in your database. Attributes from your table are referenced with pipe.attribute.
- Insert Example: INSERT INTO MyTable values ({in.Name})
- Update Example: UPDATE MyTable SET Name = {in.Name} WHERE UID = {in.UID}
- Save Apply and Close your changes.
3. Setting up the Data source
A Datasource is a connection it can be used to both collect and export data.
Existing Datasource;
- click on the Datasource icon in the toolbar.
- From the list that appears, drag the required Datasource onto your canvas.
- If you have specified a required Datasource in your data exporter it will automatically connect to it.
New Datasource;
- From the toolbar drag a Datasource onto the canvas.
- In the properties window that opens on the right set the following:
- Name, Indicative of the datasource you are connecting to.
- Database Driver, Select the appropriate database.
- Datasource instance, add a new one:
- Enter a Name.
- Enter the URL for the database.
- Specify the Username and Password.
- Tick the Enabled check box when it is ready to use.
- Tick the Enabled check box when it is ready to use.
- We recommend you tick Protect during import to prevent this datasource being updated or deleted during import.
- Other settings are optional.
- Save Apply and Close your changes.
More Information
See Datasource for all options available for a Datasource.
See SQL Updates for help creating update statements.
See SQL Insert for help creating insert statements.