database-admin is a multi-database tool plugin designed for the OpenCode AI platform, providing direct SQL access and management capabilities. It currently supports MySQL, MariaDB, PostgreSQL, SQL Server, and SQLite databases. The plugin, currently at version 1.2.1, is released as part of the OpenCode ecosystem. A key differentiating feature is its robust write protection mechanism, which mandates explicit user consent for all data modification or schema alteration operations. This consent is recorded with user identity for audit purposes. Connections are managed externally via a configuration file or through an auto-discovery mechanism that scans common project environment files (e.g., .env, appsettings.json), rather than programmatic API calls. It focuses on providing a secure, auditable, and configuration-flexible SQL interface within the OpenCode environment.
npm install database-adminVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to execute basic SQL queries using the `db` command within the OpenCode environment, showing auto-discovery, named connections, and direct URL usage.
Execute `db { "action": "consent", "grant": true }` to enable write operations. Consider using `scope: "session"` for temporary consent or `scope: "global"` for permanent access during your workflow.Be mindful of the audit logging before granting consent. For sensitive operations, consider using a more restrictive consent scope like `"operation"` or `"session"` to limit exposure.
Ensure connection files (e.g., `~/.config/opencode/db-connections.json`) are correctly formatted and accessible to OpenCode, or provide complete connection URLs directly within your `db` query commands.
Grant consent for write operations by executing `db { "action": "consent", "grant": true }` within the OpenCode interface. You can specify a `scope` (e.g., `"session"`, `"global"`) for the consent duration.Verify that `my_connection_name` is correctly defined in `~/.config/opencode/db-connections.json`, or provide a valid, complete connection URL directly in the `connection` field of your query.
Ensure that `"database-admin"` is included in the `plugins` array within your OpenCode configuration file (e.g., `~/.config/opencode/config.json`).