Reads the structure of one schema from pg_catalog through psql, or through JDBC when the db map has :jdbc-url (with :user and :password) or :datasource (a javax.sql.DataSource); the JDBC driver is then the caller's, on the classpath.
psql's connection settings are its own (PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD, PGSSLMODE, ~/.pgpass); entries in the db map override them for the call.
Result shape: {:name "public" :database_version "PostgreSQL 17.6" :tables {"users" {:name "users" :kind "TABLE" :columns [{:name :position :data_type :type_schema :is_nullable :default_value :generated_expr :identity :max_length :precision :scale}] :constraints {"users_age_check" {:name :type :columns :check_clause :is_valid :nulls_not_distinct :references :exclude}} :triggers [{:name :before :insert :update :delete}]}} :types {"mood" {:kind "ENUM" :enum_values [...]} "email" {:kind "DOMAIN" :base_type :not_null :default :constraints [{:name :definition}]}}} :kind is "TABLE", "VIEW" or "MATERIALIZED VIEW" (views have columns and no constraints); :type is one of "CHECK", "PRIMARY KEY", "UNIQUE", "FOREIGN KEY"; :references is {:match :schema :table :columns} for foreign keys, :match one of "SIMPLE", "FULL", "PARTIAL"; :is_enforced is false for a NOT ENFORCED constraint (PostgreSQL 18); :nulls_not_distinct is set for UNIQUE constraints; a unique index over plain columns is listed as a UNIQUE constraint too, with :index true (and :partial true for one with a predicate), keyed "<name> (index)" since an index may bear a constraint's name. A partitioned table carries a CHECK named "<table> (partitions)": the OR of its partitions' bounds, since it takes a row only when one of them does. :max_length is the typmod of varchar, bpchar, bit and varbit columns, of the element type for an array column. Maps keyed by object name (:tables, :constraints, :types) keep string keys; everything else is keywordized. Expressions are the strings PostgreSQL's deparser produces.
Reads the structure of one schema from pg_catalog through psql, or through JDBC when the db
map has :jdbc-url (with :user and :password) or :datasource (a javax.sql.DataSource); the
JDBC driver is then the caller's, on the classpath.
psql's connection settings are its own (PGHOST, PGPORT, PGDATABASE, PGUSER, PGPASSWORD,
PGSSLMODE, ~/.pgpass); entries in the db map override them for the call.
Result shape:
{:name "public" :database_version "PostgreSQL 17.6"
:tables {"users" {:name "users" :kind "TABLE"
:columns [{:name :position :data_type :type_schema :is_nullable
:default_value :generated_expr :identity :max_length :precision :scale}]
:constraints {"users_age_check" {:name :type :columns :check_clause :is_valid :nulls_not_distinct :references :exclude}}
:triggers [{:name :before :insert :update :delete}]}}
:types {"mood" {:kind "ENUM" :enum_values [...]}
"email" {:kind "DOMAIN" :base_type :not_null :default :constraints [{:name :definition}]}}}
:kind is "TABLE", "VIEW" or "MATERIALIZED VIEW" (views have columns and no constraints);
:type is one of "CHECK", "PRIMARY KEY", "UNIQUE", "FOREIGN KEY"; :references is
{:match :schema :table :columns} for foreign keys, :match one of "SIMPLE", "FULL", "PARTIAL";
:is_enforced is false for a NOT ENFORCED constraint (PostgreSQL 18);
:nulls_not_distinct is set for UNIQUE constraints; a unique index over plain columns is
listed as a UNIQUE constraint too, with :index true (and :partial true for one with a
predicate), keyed "<name> (index)"
since an index may bear a constraint's name. A partitioned table carries a CHECK named
"<table> (partitions)": the OR of its partitions' bounds, since it takes a row only when
one of them does. :max_length is the typmod of varchar, bpchar, bit and varbit columns,
of the element type for an array column. Maps keyed by object name (:tables, :constraints,
:types) keep string keys; everything else is keywordized. Expressions are the strings
PostgreSQL's deparser produces.(from-db)(from-db {:keys [schema] :or {schema "public"} :as db})Structure of the schema named by :schema (default "public"). :psql selects the binary; :jdbc-url (with :user and :password) or :datasource reads over JDBC instead.
Structure of the schema named by :schema (default "public"). :psql selects the binary; :jdbc-url (with :user and :password) or :datasource reads over JDBC instead.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |