Setup
Get a connection string and a role that can read the tables. Then export the string:Get a connection string
Get a connection string
- Local server:
postgres://postgres:postgres@localhost:5432/postgres. - Neon: select Connect in the console, pick the branch, database and
role, and copy the string. Neon requires
sslmode=require. - Supabase: select Connect at the top of the project and copy a string. Use the direct connection, or the session pooler on an IPv4-only network. Put the database password in it.
- Other managed servers (RDS and the like) print the string in their
dashboard. Add
?sslmode=requirewhen the server needs TLS.
Grant a read-only role
Grant a read-only role
The mount only reads. The role it connects as needs at least:Repeat the grants for each schema the mount should see.
pip install "mirage-ai[postgres]"; Node needs the pg peer
dependency (pnpm add @struktoai/mirage-node pg).
Connect
- YAML
- Python
- TypeScript
workspace.yaml
Layout
database.jsonlists every table with its estimated rows and size;schema.jsonholds columns, keys and indexes.schemaslimits the tree to those schemas. Unset, it shows all butpg_catalog,information_schemaandpg_*.- A whole read of
rows.jsonlpastmax_read_rows(10,000, counted on the rows the table really has) ormax_read_bytes(10 MiB) fails withFile too large, and so does ahead -nortail -ncount past it;wc -lcounts past it. Raise them inconfigfor bigger reads. default_row_limit(1,000) is what a windowed read with an offset but no limit returns.
Sample runs
head, tail, wc -l and grep ask Postgres for only the rows they need.
The mount is read-only: no command changes the database.
SDK guides
Python
Every config field, the VFS.md and write support.
TypeScript
Every config field, the VFS.md and write support.