What you’ll build
- A graph that holds your code and your database schema together.
- Foreign-key edges between tables.
- Queries that cross from code to schema.
Setup
Install thepostgres extra. It adds psycopg and the SQL grammar Graphify uses to parse the schema:
Step 1: Extract with a DSN
information_schema and the Postgres catalog, rebuilds the DDL, and parses it alongside your code. The connection runs SET TRANSACTION ISOLATION LEVEL SERIALIZABLE READ ONLY DEFERRABLE, so it can’t change data.
Step 2: Use PG environment variables instead
Leave the DSN empty and Graphify uses the standardPG* variables, which keeps credentials out of your shell history:
Step 3: Explore the schema
references edges between tables, and views get reads_from edges to the tables they select from. For a schema with users, orders (with a foreign key to users) and a recent_orders view, the graph holds:
[graphify extract] PostgreSQL: N nodes, M edges. Columns aren’t separate nodes, so ask about tables and their relations rather than single columns.
Step 4: Connect code to schema
--undirected, then check how your code references the table. SQL built at runtime won’t show up.
When it goes wrong
psycopg is required for --postgres. Install the extra: uv tool install "graphifyy[postgres]".
The schema adds zero nodes. The SQL grammar is missing, so parsing returns nothing. The postgres extra includes it. If you installed psycopg on its own, add tree-sitter-sql.
could not connect to PostgreSQL. Graphify trims the error to its first line so credentials don’t leak into logs. Check the host, port and role with psql using the same settings.
Production patterns
- Point Graphify at a replica or a schema-only copy, not your primary.
- Use a dedicated read-only role and pass the password through
PGPASSWORDfrom your secret manager. - Rebuild the schema graph when migrations land, for example in the CI job that runs them.
- Export to Neo4j to query code and schema in Cypher: Load your graph into Neo4j.
Complete example
What you built
One graph that holds your code and your database schema, read over a read-only connection and ready to query from the CLI, MCP or Neo4j.Next steps
Supported inputs
Every source Graphify can read.
Load your graph into Neo4j
Query code and schema together in Cypher.
Try it in Graphify
We build and host the graph for you. Start with a 14-day Pro trial, then keep up to 3 repositories on Free. No card required.