...
On this Page
Table of Contents | ||||
---|---|---|---|---|
|
...
Snap type:
Write
...
Description:
...
This Snap executes a SQL Insert statement using the document's keys as the columns to insert to and the document's values as the values to insert into the columns.
...
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
Multiexcerpt include macro | ||||
---|---|---|---|---|
|
...
This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See MySQL Account for information on setting up this type of account.
...
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 |
This Snap has at most one document error view and produces zero or more documents in the view.
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
Info |
---|
|
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.
| ||
Table name* Default value: |
...
None |
...
people | 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:
|
...
|
...
|
Default Value: Execute only
Example: Validate & Execute
...
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. There are |
...
differences in the MySQL DB version when reporting errors, for example, |
...
v5.5xx will return the expected error documents when |
...
the insert fails with a duplicate key, whereas a lower version, such as v5.0xx, does not. |
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|
Example
...
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).
...
Insert excerpt | ||||||
---|---|---|---|---|---|---|
|