Skip to content

PostgreSQL

Terminal window
usql pg://user:pass@host/dbname

Without a host, usql connects as the local user, through the Unix domain socket of the local server:

Terminal window
usql pg://

To connect without TLS, add sslmode=disable:

Terminal window
usql "pg://user:pass@host/dbname?sslmode=disable"

The driver also reads the password from the PGPASSWORD environment variable, and from the ~/.pgpass file or the file that PGPASSFILE names, as psql does. Passwords shows the ways that usql itself takes a password.

List the tables of the northwind database on PostgreSQL, and run a query over three lines.
SchemeAliasesGo driverNotes
postgrespg, pgsql, postgresqlgithub.com/jackc/pgx/v5/stdlibTransports: +unix.
pgxpxgithub.com/jackc/pgx/v5/stdlibTransports: +unix.
pqlibpqgithub.com/lib/pqTransports: +unix.