MySQL Delete

Overview

The MySQL - Delete Snap enables you to delete rows from a MySQL database table based on specified criteria. This Snap removes records that match the WHERE clause condition, providing precise control over which rows to delete.

You can use this Snap to remove obsolete, invalid, or unwanted records from your MySQL tables as part of data cleanup or maintenance workflows.



Prerequisites

A valid account with DELETE privileges on the target MySQL database table.

Limitations

When MySQL execute Snaps (MySQL Execute and MySQL Multi Execute) are followed by MySQL non-execute Snaps, such as MySQL Insert, MySQL Merge, and so on, the following error is displayed when executed:

Table definition has changed, please retry transaction.

This happens due to a known issue in the MySQL Connector. For more information about this issue, see MySQL Bug #65378.

Snap views

Type Description Examples of upstream and downstream Snaps
Input Optional.

Min: 0, Max: 1

WHERE clause for the delete condition.

Output Optional.

Min: 0, Max: 1

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 delete executed.

Optional

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

Snap settings

Legend:
  • Expression icon (): Allows using pipeline parameters to set field values dynamically (if enabled). SnapLogic Expressions are not supported. If disabled, you can provide a static value.
  • SnapGPT (): Generates SnapLogic Expressions based on natural language using SnapGPT. Learn more.
  • Suggestion icon (): Populates a list of values dynamically based on your Snap configuration. You can select only one attribute at a time using the icon. Type into the field if it supports a comma-separated list of values.
  • Upload : Uploads files. Learn more.
Learn more about the icons in the Snap settings dialog.
Field/Field set Description
Label

String
Required.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.

Default value: MySQL - Delete

Example: MySQL - Delete

Schema name

String/Expression/ Suggestion

Specify the database schema name. If it is not defined, then the suggestion for the Table Name retrieves all tables names of all schemas.

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

Default value: N/A

Example: SYS

Table name

String/Expression/ Suggestion

Required.Specify the table name to execute the delete on.

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

Default value: N/A

Example: people

Delete condition (deletes all records from table if left blank)

String/Expression

Specify the SQL WHERE clause of the delete statement. You can pass the delete condition via an upstream Snap or through the pipeline parameters.

Provide the delete conditions if a certain record or a column is to be deleted. You can also use the MySQL Select Snap to select a record name, and then specify the delete condition in the MySQL Delete Snap to delete only those particular values from the table that meet the delete condition.

Specify a valid WHERE clause for the delete condition. If you leave this field blank, all records are deleted from the table.

Default value: N/A

Examples:

Without using expressions

Using expressions

  • "EMPNO=$EMPNO and ENAME=$EMPNAME"
  • email = $email
  • emp=$emp
  • "emp='" + $emp + "'"
  • "EMPNO=" + $EMPNO + " and ENAME='" + $EMPNAME+ "'"
CAUTION: Using expressions that join strings together to create SQL queries or conditions has a potential SQL injection risk and is hence unsafe. Ensure that you understand all implications and risks involved before using concatenation of strings with '=' Expression enabled.
Number of retries

Integer

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.

Default value: 0

Example: 3

Retry interval (seconds)

Integer

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

Default value: 1

Example: 10

Snap execution

Dropdown list
Choose 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.