PostgreSQL

Connect to a PostgreSQL (or PostgreSQL-compatible) database.

Usage

sql-studio postgres [OPTIONS] <URL>

Arguments

ArgumentDescriptionEnv Var
URLPostgreSQL connection URLURL

Options

OptionDescriptionDefaultEnv Var
-s, --schemaPostgreSQL schema to usepublicSCHEMA

Connection URL Format

postgresql://user:password@host:port/database

Key-value connection strings are also accepted:

host=localhost port=5432 user=me dbname=mydb

Notes

All parts of the connection string are optional. Omitted parts use the same defaults as psql:

Examples

# Connect to a local PostgreSQL database
sql-studio postgres postgresql://postgres:postgres@127.0.0.1/sample

# Connect over the local unix socket
sql-studio postgres postgresql:///

# Connect over the local unix socket to a specific database
sql-studio postgres postgresql:///mydb

# Connect using a custom socket directory
sql-studio postgres "postgresql:///mydb?host=/path/to/socket/dir"

# Connect using a key-value connection string
sql-studio postgres "host=localhost port=5432 user=me dbname=mydb"

# Specify a schema
sql-studio postgres --schema myschema postgresql://user:pass@localhost/mydb

# Using environment variables
export URL="postgresql://user:pass@localhost/mydb"
sql-studio postgres