Kizen MySQL Connector — connect an external MySQL database to Kizen Agentic Workflows for real-time data lookups and writes.
Read-only queries against MySQL. Returns query results as strings.
- Read-only guardrail: Blocks queries starting with write/DDL keywords (
INSERT,UPDATE,DELETE,REPLACE,CREATE,DROP,ALTER,TRUNCATE,GRANT,REVOKE,LOAD,CALL) and sets the session toTRANSACTION READ ONLYbefore executing. - Smart quote normalization: Converts curly quotes
“”‘’to straight quotes beforejson.loads()to handle copy-paste from docs. - Multi-env support: Reads the
mysql_connectionsecret. Ifconnection_secret_tagis set, uses that nested key. Otherwise treats the secret as flat. - Single value mode: Set
return_single_value = trueto extract one cell. Throws if the query returns more than one row or column.
Write operations against MySQL. Returns affected row count for write queries (no result set) or query results as strings when a result set is returned.
- No SQL guardrail: Intentionally allows
INSERT,UPDATE,DELETE, etc. Use with caution. - Same secret/env handling as
mysql_read. - Single value mode also supported for write queries that return a value.
pymysql(usesDictCursorfrompymysql.cursorsfor dict-based query results)
Both steps expect a secret named mysql_connection containing a JSON string. In the nested form, set connection_secret_tag to the environment key to use (e.g., production_db).
Multi-environment (nested) form:
{
"production_db": {
"host": "db.prod.example.com",
"port": 3306,
"user_name": "app_user",
"password": "supersecret"
},
"staging_db": {
"host": "db.staging.example.com",
"port": 3306,
"user_name": "staging_user",
"password": "stagingpass"
}
}Single-environment (flat) form — used when connection_secret_tag is left empty:
{
"host": "db.prod.example.com",
"port": 3306,
"user_name": "app_user",
"password": "supersecret"
}Curly quotes (“” ‘’) in the secret value are auto-normalized to straight quotes before parsing.
| Input | Type | Required | Description |
|---|---|---|---|
database | string | yes | Database name to connect to |
query | string | yes | SQL query to execute |
return_single_value | boolean | yes | If true, expects exactly one row with one column; raises if the query returns more |
connection_secret_tag | string | no | Key to select from the mysql_connection secret. If empty, the secret is treated as flat |
Connection flow
- Finds the secret key ending in
mysql_connection. - Normalizes curly quotes and parses the JSON.
- Selects the environment via
connection_secret_tag, or uses the secret as-is if flat. - Extracts
host,port,user_name,password. - Connects to the given
databasewith a 10s timeout,utf8mb4charset, andDictCursor.
Query execution
- No rows returned →
result = "" return_single_value = true+ single row/column →result = str(value)return_single_value = true+ multiple rows/columns → raisesValueErrorreturn_single_value = false+ any rows →result = str(rows)(list of dicts)- Connection is always closed, whether the query succeeds or fails.
- SQL injection: The query input is executed directly with no parameterization. Only use with trusted queries.
- Error exposure: Errors raised on a MySQL failure include the raw MySQL error message, which may leak schema info.
mysql_writeintentionally allows write/DDL statements — scope secrets and credentials accordingly.
| Issue | Cause | Fix |
|---|---|---|
| Error decoding JSON | Curly quotes or malformed JSON in the secret | Curly quotes auto-fix; check the rest of the JSON syntax |
| Missing required key(s) | Secret missing host, port, user_name, or password | Verify the secret structure |
| Query returned no rows | Valid query with an empty result set | Expected behavior — result is "" |
Expected a single value result... | return_single_value = true but the query returned more than one row/column | Set return_single_value = false or adjust the query |
Error while using MySQL connection | MySQL error during connect or query | Check the logged MySQL error for details |
GPL-2.0 — see LICENSE.md.