Connectivity
Connect to your database
ArmorDB provides standard PostgreSQL connection strings that work with any compatible driver or tool. All connections require SSL/TLS for security.
Connection URL Format
The connection string follows the standard URI format. You can find your specific string in the Connect section of any database in your dashboard.
uri
postgresql://[USER]:[PASSWORD]@[HOST]:[PORT]/[DATABASE]?sslmode=requireConnecting with psql
The psql command-line tool is the fastest way to verify your connection.
bash
psql "postgresql://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=require"Node.js (pg)
When using the pg library, ensure you enable SSL and handle pool connections efficiently.
javascript
import pg from "pg";
const pool = new pg.Pool({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false, // Required for most hosted environments
},
});
const client = await pool.connect();
try {
const res = await client.query('SELECT NOW()');
console.log(res.rows[0]);
} finally {
client.release();
}Python (psycopg)
Python applications typically use psycopg. Connection pooling via PgBouncer is highly recommended.
python
import os
import psycopg
# Connection string from environment
conn_str = os.environ.get("DATABASE_URL")
with psycopg.connect(conn_str) as conn:
with conn.cursor() as cur:
cur.execute("SELECT version();")
record = cur.fetchone()
print(f"Connected to: {record}")Pro Tip: Connection Pooling
ArmorDB includes a high-performance PgBouncer layer by default. For serverless or high-concurrency applications, always use the pooled connection port to prevent exhaustion of system resources.
