MySQL binding spec

To setup MySQL binding create a component of type . See on how to create and apply a binding configuration.

The MySQL binding uses Go-MySQL-Driver internally.

Warning

The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described here.

If your server requires SSL your connection string must end of &tls=custom for example:

  1. "<user>:<password>@tcp(<server>:3306)/<database>?allowNativePasswords=true&tls=custom"

This component supports output binding with the following operations:

  • exec
  • query
  • close

The exec operation can be used for DDL operations (like table creation), as well as , UPDATE, DELETE operations which return only metadata (e.g. number of affected rows).

Request

Response

  1. "metadata": {
  2. "operation": "exec",
  3. "duration": "294µs",
  4. "start-time": "2020-09-24T11:13:46.405097Z",
  5. "end-time": "2020-09-24T11:13:46.414519Z",
  6. "rows-affected": "1",
  7. "sql": "INSERT INTO foo (id, c1, ts) VALUES (1, 'demo', '2020-09-24T11:45:05Z07:00')"
  8. }
  9. }

Request

Response

  1. {
  2. "metadata": {
  3. "operation": "query",
  4. "duration": "432µs",
  5. "end-time": "2020-09-24T11:13:46.420566Z",
  6. "sql": "SELECT * FROM foo WHERE id < 3"
  7. },
  8. "data": "[
  9. [0,\"test-0\",\"2020-09-24T04:13:46Z\"],
  10. [1,\"test-1\",\"2020-09-24T04:13:46Z\"],
  11. [2,\"test-2\",\"2020-09-24T04:13:46Z\"]
  12. ]"

Finally, the close operation can be used to explicitly close the DB connection and return it to the pool. This operation doesn’t have any response.

Request

Last modified November 12, 2021 :