Skip to content

MySQL Query

The MySQL Query module allows executing SQL queries directly on a MySQL database. It supports dynamic variables in the query, including advanced syntax like {{@NodeName.field}}, {{#N.field}} and {{var.name}} to reference data from other workflow nodes. It is ideal for reading, inserting, updating or deleting records in MySQL as part of an automated workflow.

ParameterTypeRequiredDescription
credentials_idcredentialsYesMySQL connection credentials
querycodeYesSQL query to execute (supports {{variable}} variables)

The credential must contain the fields:

  • host: MySQL server address
  • user: Database user
  • password: User password
  • database: Database name
  • port: Connection port (default: 3306)
{
"nextModule": "siguiente_modulo",
"data": [
{ "id": 1, "nombre": "Ejemplo", "email": "test@test.com" },
{ "id": 2, "nombre": "Ejemplo 2", "email": "test2@test.com" }
]
}
{
"credentials_id": "cred_mysql_01",
"query": "SELECT * FROM usuarios WHERE estado = 'activo' LIMIT 100"
}
{
"credentials_id": "cred_mysql_01",
"query": "SELECT * FROM pedidos WHERE cliente_id = '{{clienteId}}'"
}
  • Supports dynamic variables {{variable}} in the SQL query
  • Supports advanced syntax: {{@NodeName.field}} to reference data from other nodes, {{#N.field}} to reference by index, {{var.name}} for memory variables
  • Uses the mysql2/promise library for connections
  • If the server’s authentication plugin is not compatible (such as auth_gssapi_client), a descriptive error message is shown
  • The connection is automatically closed after each execution
  • In case of SQL error, the executed query is included in the error message for easier debugging
  • It is recommended not to use this query for destructive operations without prior validation
  • sqlQueryMSSQL (SQL Server queries)
  • sqlQueryPostgres (PostgreSQL queries)
  • sqlQueryPostgresSSL (PostgreSQL queries with SSL)
  • sqlQueryOracle (Oracle queries)