Connection string
A PostgreSQL connection string usually looks like this:Test with psql
TLS
Use TLS for application connections. If your framework supportssslmode=require, keep it enabled in production.
Application examples
- Node.js
- Ruby
- Python
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Connect applications, psql, and database tools to a LayerRail PostgreSQL database using connection strings, TLS, and connection pooling.
postgresql://<user>:<password>@<host>:5432/<database>?sslmode=require
export DATABASE_URL="postgresql://<user>:<password>@<host>:5432/<database>?sslmode=require"
psql "$DATABASE_URL"
select version();
sslmode=require, keep it enabled in production.
postgresql://<user>:<password>@<host>:5432/<database>?sslmode=require
import pg from "pg";
const pool = new pg.Pool({
connectionString: process.env.DATABASE_URL,
ssl: { rejectUnauthorized: false }
});
require "pg"
conn = PG.connect(ENV.fetch("DATABASE_URL"))
puts conn.exec("select now()").first
import os
import psycopg
with psycopg.connect(os.environ["DATABASE_URL"]) as conn:
print(conn.execute("select now()").fetchone())
Was this page helpful?
