MySQL - Insert
On this Page
Overview
You can use this Snap to execute a SQL Insert statement.
Snap Type
The MySQL - Insert Snap is a Wrte-type Snap.
Prerequisites
None.
Support for Ultra Pipelines
Works in Ultra Pipelines when batch size is set to 1.
Known Issues
None.
Limitations
Behavior Change
Previously, when you passed Date/DateTime
value for the Year data type column, the MySQL Insert Snap inserted the value into Year
data type.
With the 4.37 GA release, when you pass a Date/DateTime
value for the Year
data type column, the Insert Snap does not accept those values and fails with an error. We recommend that you pass only year values for the Year
data type. This is the expected behavior of the Snap.
Snap Views
Type | Format | Number of Views | Examples of Upstream and Downstream Snaps | Description |
---|---|---|---|---|
Input | Binary  |
|
| This Snap has two input views but by default it has one input view. |
Output | Document  |
|
| This Snap has at most one document output view. If an output view is available, then the original document that was used to create the statement will be output with the status of the insert executed. |
Error | Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab:
Learn more about Error handling in Pipelines. Database write Snaps output all records of a batch (as configured in your account settings)Â to the error view if the write fails during batch processing. |
Snap Settings
Asterisk (*): Indicates a mandatory field.
Suggestion icon (): Indicates a list that is dynamically populated based on the configuration.
Expression icon (): Indicates whether the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.
Add icon (): Indicates that you can add fields in the field set.
Remove icon (): Indicates that you can remove fields from the field set.
Â
Field Name | Field Type | Description |
---|---|---|
Label* Â Default value:Â MySQL - Insert | String | Specify the name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your pipeline. |
Schema name  Default value: None | String/Expression/Suggestion | Specify the database schema name. In case it is not defined, then the suggestion for the Table Name will retrieve all tables names of all schemas. The property is suggestable and will retrieve available database schemas during suggest values. The values can be passed using the pipeline parameters but not the upstream parameter.  |
Table name* Â Default value:Â None | String/Expression/Suggestion | Specify the name of table to execute insert on. |
Create table if not present  Default value:  Deselected | Checkbox | |
Number of retries  Default Value: 0 | Integer/Expression | Specify the maximum number of attempts to make to receive a response. The request is terminated if the attempts do not result in a response.  |
Retry interval (seconds)  Default Value: 1 | Integer/Expression | Specify the time interval between two successive retry requests. A retry happens only when the previous attempt resulted in an exception. |
Use MySQL INSERT IGNORE option  Default Value: Fail | String/Expression | Choose an option to instruct the Snap to ignore the SQL errors encountered during execution. |
Snap Execution  Default Value: Execute only | Dropdown list | Select one of the three modes in which the Snap executes. Available options are:
 |
Troubleshooting
Error Scenario | Resolution |
---|---|
If the MySQL Insert batch fails due to a duplicate primary key, the error message from MySQL contains a reference to the first row failed, for example, "Duplicate entry '10000' for key 'PRIMARY'". Those rows before the first failed row in the batch get successfully inserted and the ones after the failed row are not processed, but MySQL returns with a mark of all rows failed. You will see the same error message with the reference to the first failed row in all rows in the error view. | If you want to see accurate referencing to the failed row in the error message, you can change the Batch size to 1 in the account and execute or preview the pipeline. You will see successful rows passed to the output view and failed rows to the error view with accurate reference. |
Examples
Insert records in a table
This example pipeline demonstrates how to insert records to an existing table using the JSON Generator Snap and map them to the MySQL table 'Hues' using the Mapper and the MySQL Insert Snaps, respectively. The failed records are routed to the error view.
Configure the JSONÂ Generator Snap to pass the values to the Mapper Snap.
Configure the Mapper Snap to map the records to the respective columns on the table.
The output preview of the Mapper Snap displays the added records.
Configure the MYSQL Insert Snap to insert the records into the table 'Hues' on the 'Snaplogic' Schema.
The failed records are routed to the error view, which displays the reason that the column 'rgb' is unknown in the field list (indicating that the column rgb is absent in the existing table, and hence, the two records with the RGB values are routed to the error view).
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2024 SnapLogic, Inc.