MySQL - Insert

On this Page


You can use this Snap to execute a SQL Insert statement.


Snap Type

The MySQL - Insert Snap is a Wrte-type Snap.



Support for Ultra Pipelines

Works in Ultra Pipelines when batch size is set to 1.

Known Issues



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



Number of Views

Examples of Upstream and Downstream Snaps




Number of Views

Examples of Upstream and Downstream Snaps





  • 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.




  • 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 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

  • 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


Field Name

Field Type




Default value: MySQL - Insert
Example: MySQL - Insert


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


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


Specify the name of table to execute insert on.

Create table if not present


Default value:  Deselected


Number of retries


Default Value: 0


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


Specify the time interval between two successive retry requests. A retry happens only when the previous attempt resulted in an exception. 



Default Value: Fail
Example: Ignore


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

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.



Error Scenario


Error Scenario


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.


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).