Connect to your database
ArmorDB provides standard PostgreSQL connection strings that work with any compatible driver or tool. The public pooled gateway at db.armordb.org:6432 and direct endpoint at db.armordb.org:5432 require SSL/TLS and rejects plaintext connections. It uses a publicly trusted certificate. Direct TLS access is available at db.armordb.org:5432 for migrations and session-level features.
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.
postgresql://[USER]:[PASSWORD]@[HOST]:[PORT]/[DATABASE]?sslmode=verify-fullConnecting with psql
The psql command-line tool is the fastest way to verify your connection.
psql "postgresql://USER:PASSWORD@HOST:PORT/DATABASE?sslmode=verify-full"Node.js (pg)
When using the pg library, ensure you enable SSL and handle pool connections efficiently.
import pg from "pg";
const pool = new pg.Pool({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: true, // Verify the publicly trusted gateway certificate
},
});
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.
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.
