Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

On this Page

Table of Contents
maxLevel2
excludeOlder Versions|Additional Resources|Related Links|Related Information

...

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
nameMySQLKI
pageMySQL Snap Pack

...

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

 

  • Min: 1

  • Max: 1

  • MySQL -Execute

  • MySQL - Select

  • Mapper

This Snap has two input views but by default it has one input view.
You can add a second view for metadata for the table as a document so that the table is created in MySQL with a similar schema as the source table. This schema is usually from the second output of a database Select Snap. If the schema is from a different database, the data types might not be properly handled.

Output

Document

 

  • Min: 1

  • Max: 2

  • Mapper

  • Copy

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:

  • Stop Pipeline Execution: Stops the current Pipeline execution if the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the remaining records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

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
  • Asterisk (*): Indicates a mandatory field.

  • Suggestion icon ((blue star)): Indicates a list that is dynamically populated based on the configuration.

  • Expression icon ((blue star)): Indicates whether the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.

  • Add icon ((blue star)): Indicates that you can add fields in the field set.

  • Remove icon ((blue star)): Indicates that you can remove fields from the field set.

Field Name

Field Type

Description

Label*

Default value: MySQL - Insert
Example: 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
Example: SYS

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.

Note

The values can be passed using the pipeline parameters but not the upstream parameter.

Table name*

Default value:

...

 None
Example

...

people

String/Expression/Suggestion

Specify the name of table to execute insert on.

Note

The values can be passed using the pipeline parameters but not the upstream parameter.

...


Create table if not present

Default value:  Deselected


Checkbox

Multiexcerpt include macro
nameME_Create_Table_Automatically_2_Inputs
pageRedshift - Bulk Load

Number of retries

Default

...

Select this check box to specify whether the letter case used in column labels must be preserved while performing the insert operation. Selecting this option ensures that the precise cases used are retained.

...

Value:

...

0
Example3

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
Example10

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
Example: Ignore

String/Expression

Choose an option to instruct the Snap to ignore the SQL errors encountered during execution.

Note

If the target table contains no primary key constraint, and the 'Use MySQL INSERT IGNORE option' is set to ignore, then the Snap inserts null values into MySQL when you attempt to insert invalid data.

To ensure that all data truncation / validation errors are caught in the error view, set the 'Use Mysql INSERT IGNORE option' to Fail.

Snap Execution

Default Value: Execute only
Example: Validate & Execute

Dropdown list

Select one of the three modes in which the Snap executes. Available options are:

  • Validate & Execute: Performs limited execution of the Snap, and generates a data preview during Pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during

...

  • pipeline runtime.

  • Execute only: Performs full execution of the Snap during

...

  • pipeline execution without generating preview data.

  • Disabled: Disables the Snap and all Snaps that are downstream from it.

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
Azure SQL - Bulk Load
Azure SQL - Bulk Load
nopaneltrue

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
MySQL Snap Pack
MySQL Snap Pack
nopaneltrue