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:
"<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
"metadata": {
"operation": "exec",
"duration": "294µs",
"start-time": "2020-09-24T11:13:46.405097Z",
"end-time": "2020-09-24T11:13:46.414519Z",
"rows-affected": "1",
"sql": "INSERT INTO foo (id, c1, ts) VALUES (1, 'demo', '2020-09-24T11:45:05Z07:00')"
}
}
Request
Response
{
"metadata": {
"operation": "query",
"duration": "432µs",
"end-time": "2020-09-24T11:13:46.420566Z",
"sql": "SELECT * FROM foo WHERE id < 3"
},
"data": "[
[0,\"test-0\",\"2020-09-24T04:13:46Z\"],
[1,\"test-1\",\"2020-09-24T04:13:46Z\"],
[2,\"test-2\",\"2020-09-24T04:13:46Z\"]
]"
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 :