Postgres

The sq Postgres driver implements connectivity for the Postgres database. The driver implements all optional driver features.

Add source

Use sq add to add a source. The location argument should start with postgres://. For example:

sq add 'postgres://sakila:p_ssW0rd@localhost/sakila'

Non-default schema

By default, the Postgres driver connects to the default public schema. To use an alternate schema, add the search_path param to the location string when adding the Postgres source.

For example, to use the customer schema:

sq add 'postgres://sakila:p_ssW0rd@localhost/sakila?search_path=customer'

Note that the location string should be quoted due to the ? character.

Inspect field provenance

sq inspect populates the fields below from the Postgres system catalogs.

Source-level fields

FieldSource
name, catalogcurrent_catalog
schemacurrent_schema()
usercurrent_user
db_productversion() (full descriptive string, e.g. PostgreSQL 12.16 on aarch64-unknown-linux-musl …)
db_versioncurrent_setting('server_version') (numeric, e.g. 12.16)
sizepg_database_size(current_catalog) — total on-disk size of the current database

Per-table fields

FieldSource
row_countlive SELECT COUNT(*)
sizepg_total_relation_size('tbl') — table data plus its indexes and TOAST segments