Read a PostgreSQL database
Describe a connection, pull the schema into a project and pull again without losing identity.
databee pull reads the structure of a database into the project. For PostgreSQL it reads versions 15 to 19.
A connection profile
Connections can be given as a URL, but a profile keeps secrets out of the project and out of your shell history. Profiles live in connections.toml in the databee configuration directory: $DATABEE_CONFIG_DIR, else $XDG_CONFIG_HOME/databee, else ~/.config/databee.
[connections.shop]
url = "postgres://app@localhost:5432/shop"
password = "env:SHOP_DB_PASSWORD"
The password is read from the named environment variable (env:NAME). A URL that contains a password still works but produces the warning DB-CFG-001. Check the profile:
databee connection list
databee connection test shop
Neither command prints a password.
Pull
databee init --name shop
databee pull --connection shop
Without --connection, pull takes --url, then DATABASE_URL. --schema <name> (repeatable) limits the pull to some namespaces. The dialect is taken from the URL scheme, so the same command reads MySQL (mysql://), MariaDB (mariadb://), SQLite (sqlite:path), SQL Server (mssql:// or sqlserver://) and MongoDB (mongodb://); see the capability matrix for what each one captures.
What a pull keeps
Every table, column, key and index gets a stable ID in the model. Pull again after the database changed and the IDs stay: a table or column that was renamed in PostgreSQL is recognised by its catalog identity and keeps its ID, so snapshots and plans see a rename, not a drop and a create.
What databee cannot represent is reported, not dropped silently. Objects such as views, partitioned tables and exclusion constraints, and sequences that no column owns, come back as DB-INT-001 warnings (“… is not captured”). Sequences owned by a column (serial, bigserial, smallserial, OWNED BY) are read into the column.
Next
Validate and lint the result, or render it as a diagram.