Connection strings
A connection string is required to connect to your RayDB PostgreSQL cluster from applications, command-line tools, and database management interfaces. This guide explains how to retrieve and use your cluster’s connection string.
Retrieving Your Connection String
-
Log in to the RayDB Dashboard.
-
Navigate to the Clusters section and select the cluster you want to connect to.
-
In the Cluster Details page, locate the Connection Information section.
-
Copy the provided connection string. It will typically be in the following format:
postgres://<user>:<password>@<host>:<port>/<database>?sslmode=require
Using the Connection String
The connection string can be used with different tools and programming environments:
psql (Command-Line Tool)
To connect using psql, run:
psql <connection-string>pgAdmin
When adding a new connection in pgAdmin, use the connection string in the Connection tab.
Application Code
Most database drivers accept connection strings directly. Example in Python using psycopg2:
import psycopg2
conn = psycopg2.connect("postgres://user:password@host:port/database?sslmode=require")Secure Connection Management
- Use Environment Variables: Store connection strings securely in your environment variables instead of hardcoding them.
- Rotate Credentials Regularly: Update passwords and credentials periodically for security.
- Restrict IP Access: Configure firewall settings to limit access only to trusted sources.
For further details, proceed to Firewall Configuration to manage access controls.