You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: POSTGRESQL.md
+37Lines changed: 37 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,10 @@ software delivery cycle.
6
6
7
7
# Setup
8
8
9
+
## Required Gemini CLI Version
10
+
11
+
To install this extension, the Gemini CLI version must be v0.6.0 or above. The version can be found by running: `gemini --version`.
12
+
9
13
## PostgreSQL MCP Server (Data Plane: Connecting and Querying)
10
14
11
15
This section covers connecting to a PostgreSQL database instance.
@@ -24,3 +28,36 @@ This section covers connecting to a PostgreSQL database instance.
24
28
likely that the user do not have the correct privileges on the PostgreSQL
25
29
database. Database-level permissions (e.g., `SELECT`, `INSERT`) are required
26
30
to execute queries.
31
+
32
+
---
33
+
34
+
# Usage Guidelines
35
+
36
+
## Connecting to New Resources
37
+
38
+
You will need to perform the following steps to change the current database connection:
39
+
40
+
1.**(Optional) Save your conversation:** To avoid losing your progress, save the current session by running the command: `/chat save <your-tag>`
41
+
2.**Stop the CLI:** Terminate the Gemini CLI.
42
+
3.**Update Environment Variables:** Set or update your environment variables (e.g. `POSTGRES_DATABASE`) to point to the new resource.
43
+
4.**Restart:** Relaunch the Gemini CLI
44
+
5.**(Optional) Resume conversation:** Resume your conversation with the command: `/chat resume <your-tag>`
45
+
46
+
## Reusing Project Values
47
+
48
+
Users may have set project environment variables:
49
+
50
+
*`POSTGRES_HOST`: The hostname or IP address of the PostgreSQL server.
51
+
*`POSTGRES_PORT`: The port number of the PostgreSQL server.
52
+
*`POSTGRES_DATABASE`: The name of the database to connect to.
53
+
*`POSTGRES_USER`: The username for authentication.
54
+
*`POSTGRES_PASSWORD`: The password for authentication.
55
+
56
+
Instead of prompting the user for these values for specific tool calls, prompt the user to verify reuse a specific value.
57
+
Make sure to not use the environment variable name like `POSTGRES_HOST`, `${POSTGRES_HOST}`, or `$POSTGRES_HOST`. The value can be found by using command: `echo $POSTGRES_HOST`.
58
+
59
+
## Use Full Table Name Format "DATABASE_NAME.SCHEMA_NAME.TABLE_NAME"
60
+
61
+
**ALWAYS** use the full table name format, `DATABASE_NAME.SCHEMA_NAME.TABLE_NAME` in the generated SQL when using the `execute_sql` or `postgres__execute_sql` tool.
62
+
* Default to using "public" for the schema name.
63
+
* Use command `echo $POSTGRES_DATABASE` to get the current database value.
Set the following environment variables before starting the Gemini CLI:
35
37
@@ -39,6 +41,19 @@ Set the following environment variables before starting the Gemini CLI:
39
41
*`POSTGRES_USER`: The username for authentication.
40
42
*`POSTGRES_PASSWORD`: The password for authentication.
41
43
44
+
### Start Gemini CLI
45
+
46
+
To start the Gemini CLI, use the following command:
47
+
48
+
```bash
49
+
gemini
50
+
```
51
+
52
+
> [!WARNING]
53
+
> **Changing Instance & Database Connections**
54
+
> Currently, the database connection must be configured before starting the Gemini CLI and can not be changed during a session.
55
+
> To save and resume conversation history use command: `/chat save <tag>` and `/chat resume <tag>`.
56
+
42
57
## Usage Examples
43
58
44
59
Interact with Postgres using natural language right from your IDE:
@@ -67,8 +82,12 @@ Interact with Postgres using natural language right from your IDE:
67
82
68
83
## Additional Extensions
69
84
70
-
Find additional extensions to support your entire software development lifecycle at [github.com/gemini-cli-extensions](https://github.com/gemini-cli-extensions).
85
+
Find additional extensions to support your entire software development lifecycle at [github.com/gemini-cli-extensions](https://github.com/gemini-cli-extensions), including:
86
+
*[Cloud SQL for PostgreSQL extension](https://github.com/gemini-cli-extensions/cloud-sql-postgresql)
87
+
* and more!
71
88
72
89
## Troubleshooting
73
90
74
-
* "cannot execute binary file": Ensure the correct binary for your OS/Architecture has been downloaded. See [Installing the server](https://googleapis.github.io/genai-toolbox/getting-started/introduction/#installing-the-server) for more information.
91
+
* "✖ Error during discovery for server: MCP error -32000: Connection closed": The database connection has not been established. Ensure your configuration is set via environment variables.
92
+
* "✖ MCP ERROR: Error: spawn /Users/<USER>/.gemini/extensions/postgres/toolbox ENOENT": The Toolbox binary did not download correctly. Ensure you are using Gemini CLI v0.6.0+.
93
+
* "cannot execute binary file": The Toolbox binary did not download correctly. Ensure the correct binary for your OS/Architecture has been downloaded. See [Installing the server](https://googleapis.github.io/genai-toolbox/getting-started/introduction/#installing-the-server) for more information.
0 commit comments