Switch Default Database
db_use_databaseSet the default database for subsequent PostgreSQL queries in the current session. Switch between databases to direct all following operations without specifying a database each time.
Instructions
Switches the default database for subsequent tool calls. After switching, all tools that accept an optional 'database' parameter will use this database when the parameter is omitted. The target database must be listed in pgautopilot.json. This is an idempotent operation — calling it with the same database name has no effect.
When to use:
After calling db_list_databases, when the user wants to work with a specific database.
When switching between production and analytics databases mid-session.
Behavioral notes:
The target database is lazily connected on first use if not already connected.
If the target database is unreachable, the switch succeeds but subsequent tools will return a connection error with guidance.
This does NOT affect other MCP sessions or connections — only the current session.
Returns: confirmation with the new default database name and its connection details.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database | Yes | Name of the database to switch to as the default |