Automations

MySQL Query Node

5 min readnode-data-mysql

Run a parameterised SELECT, INSERT, or UPDATE against an external MySQL or MariaDB database from within an automation step.

MySQL Query Node

The MySQL Query node opens a connection to an external MySQL/MariaDB database, executes a parameterised query, and stores the result set as a flow variable.

> Security: Always use parameterised queries (? placeholders) — never interpolate user input directly into the SQL string. The node uses mysql2 under the hood, which protects against SQL injection when placeholders are used correctly.

---

Fields
FieldTypeRequiredDescription
hoststringYesDatabase host (IP or hostname)
portintegerNoDefault: 3306
databasestringYesDatabase name
userstringYesDB username
passwordstringYesDB password — reference a saved credential: {{credentials.myDbCred}}
sslbooleanNoEnable TLS (recommended for remote databases)
querystringYesParameterised SQL. Use ? for parameters
paramsstringNoJSON array of values for the ? placeholders
outputVarstringNoVariable name to store results (default: queryResult)

---

Output variables
VariableDescription
{{variables.queryResult}}Array of row objects for SELECT; affectedRows integer for INSERT/UPDATE/DELETE

---

Example: look up a customer record

json { "host": "db.mycompany.com", "database": "crm", "user": "readonly", "password": "{{credentials.crmDbPassword}}", "query": "SELECT id, name, plan FROM customers WHERE email = ? LIMIT 1", "params": "["{{lead.email}}"]", "outputVar": "customer" }

Access result: {{variables.customer[0].plan}}

---

Example: log a touchpoint

json { "query": "INSERT INTO touchpoints (lead_email, action, created_at) VALUES (?, ?, NOW())", "params": "["{{lead.email}}", "email_sent"]" }

---

Tips
  • Store DB passwords in Settings → Credentials — never paste them raw into the node config
  • Use ssl: true for any database not on the same private network
  • SELECT queries return an array — if you expect one row, use {{variables.customer[0].name}} to access it
  • The connection is closed after each execution — there's no persistent connection pool per automation