Mysql Client
Read-only client for MySQL and Aurora MySQL. Checks connectivity, runs parameterized SELECT queries and snapshots table and column metadata, all stored as swamp data.
The network path is yours: point host and port at the database, or at
the local end of a tunnel or port-forward you start yourself. The model
opens no tunnels and runs no other programs. When nothing is listening it
says so instead of printing a socket error.
Writes are refused twice: query only accepts SELECT, WITH, SHOW,
DESC/DESCRIBE and EXPLAIN statements, and runs them inside a read-only
transaction that is always rolled back.
Quick Start
swamp extension pull @cachehit/mysql-client
# Store the database credentials (prompts for each value)
swamp vault create local_encryption db
swamp vault put db USER
swamp vault put db PASSWORD
swamp model create @cachehit/mysql-client my-db \
--global-arg host=127.0.0.1 \
--global-arg port=3308 \
--global-arg database=app \
--global-arg 'user=${{ vault.get("db", "USER") }}' \
--global-arg 'password=${{ vault.get("db", "PASSWORD") }}'
swamp model method run my-db check
swamp model method run my-db query --input-file queries.yaml
swamp model method run my-db schemaMethods
- check: connect and record the server version, Aurora version (null on plain MySQL), current user, database and read-only flag.
- query: run one or more named, parameterized read statements over a
single connection. Each result is stored as
result-<name>with its columns, rows, row count, truncation flag and duration. - schema: record the tables and columns of a database from
information_schemaasschema-<database>.
Added: First release. check, query and schema connect to a MySQL or Aurora MySQL endpoint, run read-only
parameterized queries and record table metadata as swamp data.
Global Arguments
| Argument | Type | Description |
|---|---|---|
| host? | string | Host to connect to, typically the local end of your port-forward |
| port? | number | TCP port to connect to, typically the local end of your port-forward |
| database? | string | Default database (schema) to use; optional |
| user | string | MySQL user name |
| password | string | MySQL password (store in a vault and reference it via CEL) |
| connectTimeoutMs? | number | Connect timeout in milliseconds |
| Argument | Type | Description |
|---|---|---|
| queries | array | |
| maxRows? | number | Maximum rows kept per query; extra rows are dropped and truncated is set |
| Argument | Type | Description |
|---|---|---|
| database? | string | Database to describe; defaults to the global database |
Resources
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit2/2earned
- Docs keep secrets in a vault1/1earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License2/2earned
- Verified public repository2/2earned