Check the connection and its privileges
db_healthCheck whether a database is reachable, its version, authenticated role, read-only status, object counts, and pool state to diagnose failed connections or writes.
Instructions
Ask the database about itself: reachable or not, server version, the role this server authenticated as, whether that role or the server is read-only, object counts, and this server's pool and cache state. Use it instead of guessing at why a connection or a write failed. Note what "readOnly": false does and does not do: it is a request to THIS server, not a security boundary. The boundary is the database role -- a role holding INSERT will succeed whatever these flags say, and a role without them will fail however many are set.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uri | No | Connection string, for example postgres://user@host/db, mysql://user@host/db, sqlite:///path/to/app.db, mongodb://host/db or redis://host. Pass "profile" wherever db_list shows one. | |
| profile | No | A profile name from db_list. Exactly one of "profile" (a name from db_list) or "uri" (an ad-hoc connection string). Prefer "profile": it keeps the password out of the transcript. | |
| timeout | No | Milliseconds before giving up on the diagnostics (default 30000, between 1 and 86400000). |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ok | Yes | False when the call failed; read "error" then. | |
| pool | No | This server's connection cache. | |
| role | No | The database user this server authenticated as. | |
| error | No | Present only when "ok" is false. | |
| checks | Yes | One {name, ok, detail} per diagnostic. A failed one is a finding, not an error. | |
| drivers | No | Which native drivers are installed and loadable. | |
| objects | No | Object counts by kind, for example {"tables":12}. | |
| database | Yes | Driver that answered. | |
| profiles | No | ||
| reachable | Yes | False when no connection could be made at all. | |
| readOnlyRole | No | Whether the role and the server together look read-only, from a read-only probe. Null when the driver cannot answer that. | |
| serverVersion | No |