> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphify.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> The PyPI package is graphifyy, with two y's. The command is graphify.
> /graphify . is typed in an assistant chat, not in a shell.
> Use only commands, flags, and endpoints shown on these pages. Do not invent one.
> Choose the surface before you open a page. Local (Graphify Local) is the graphifyy package on the machine: the skill, the CLI, and the ten-tool MCP. Its pages are the Open Source tab (/open-source/) and the Graphify Local tab on each Integrations page. Graphify is the hosted workspace and https://api.graphify.com/mcp (Streamable HTTP, OAuth, no API key). Its pages are the Graphify tab (/platform/, /concepts/) and the Graphify (hosted) tab on each Integrations page. Prefer Graphify unless the user asks for a local or offline setup. Cookbooks (/cookbooks/) and /mcp/docs-search apply to both. Each page's source frontmatter records this as surface: local, cloud, or both. Buildkite is the CI integration.
> In llms.txt, tell the surface from the page path. Graphify: /platform/ and /concepts/. Local: /open-source/. Most /integrations/ pages cover both, with a Graphify (hosted) tab and a Graphify Local tab. Everything else applies to both.
> graphifyy release notes are published at https://github.com/Graphify-Labs/graphify/releases and https://graphify.com/changelog. The current package version is on PyPI (https://pypi.org/project/graphifyy/).
> The official site is https://graphify.com. These docs are https://docs.graphify.com.
> The local MCP server is the ten tools in the MCP tool reference and reads a graph on the machine. The hosted server is https://api.graphify.com/mcp (Streamable HTTP, OAuth, no API key). The JetBrains, ChatGPT, Codex, and Dots, and Vercel pages use the hosted server, not the ten-tool list. On pages with tabs, the Graphify (hosted) tab uses the hosted server and the Graphify Local tab uses the local skill or the ten-tool server.
> Read https://docs.graphify.com/llms.txt, then open one page's .md link. Use https://docs.graphify.com/llms-full.txt only when one page is not enough.

# Databases and package graphs

> Map a live PostgreSQL schema and Rust crate dependencies into your Graphify Local graph, alongside the code that uses them.

The code that queries a table is only half the picture. Graphify Local can read your database schema and your Rust workspace's crate graph, so your agent sees tables, views, functions, foreign keys, and crate dependencies next to the code.

> [!NOTE]
>
> **Use this when** you're changing a table or a shared crate and want to know what depends on it.

## Sources

| Source | How | What you get |
| - | - | - |
| `.sql` files in the repo | Parsed automatically | Tables, views, and functions defined in the files |
| A live PostgreSQL database | `graphify extract --postgres <DSN>` | Tables, views, functions, and foreign-key relationships |
| A Rust workspace | `graphify extract --cargo` | Crate-to-crate dependencies |

Columns are not represented as separate nodes.

## How PostgreSQL introspection works

**1. Connect read-only**

Graphify opens a `READ ONLY` serializable transaction. It never writes to your database.

**2. Read the catalog**

It lists tables, views, and routines from `information_schema`, skipping the system schemas.

**3. Rebuild DDL**

It reconstructs the schema as SQL and runs it through the same parser used for `.sql` files.

If the connection fails, the error message is trimmed so your DSN and password don't end up in logs.

## See it in action

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
pip install "graphifyy[postgres]"
graphify extract . --postgres "postgresql://readonly@localhost:5432/app"
```

Pass an empty DSN to use the standard `PGHOST`, `PGUSER`, `PGPASSWORD`, and `PGDATABASE` environment variables, which keeps the password out of your shell history:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
export PGHOST=localhost PGUSER=readonly PGDATABASE=app
graphify extract . --postgres ""
```

For a Rust workspace:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
graphify extract . --cargo
```

Then ask about it like any other node:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
graphify explain "orders"
graphify path "orders" "checkout"
```

## Configure

**Least privilege**

Create a role that can read the catalog and nothing else. Graphify needs no access to table data.

**CI**

Store the DSN as a secret and pass it through `PG*` variables in your job. See [Headless extraction](https://docs.graphify.com/open-source/features/headless-extraction.md).

## Verify and troubleshoot

| Symptom | Fix |
| - | - |
| `psycopg is required for --postgres` | `pip install "graphifyy[postgres]"` |
| `could not connect to PostgreSQL` | Check host, port, and role. The full error is hidden to protect credentials; test with `psql` first. |
| Tables missing | Only non-system schemas the role can see are read. Grant usage on the schema. |
| No crate edges | Run from your Rust workspace, or a folder under it, so Graphify can find the root `Cargo.toml`. |

> **Which databases are supported?**
>
> PostgreSQL for live introspection. Any dialect the SQL parser understands works from `.sql` files.

> **Does Graphify read rows?**
>
> No. Only catalog metadata: names, definitions, and relationships.

## Flags

| Flag | What it does |
| - | - |
| `--postgres DSN` | Reads tables, views, functions and foreign keys from a live database. Column-level detail isn't represented in the graph. |
| `--cargo` | Extracts crate-to-crate dependencies from `Cargo.toml`. |
| `--code-only` | Skips documents. SQL files are still extracted as code. |

The `postgres` extra installs both `psycopg[binary]` and `tree-sitter-sql`. Introspection rebuilds DDL and parses it with the SQL grammar, and without that grammar it returns 0 nodes. If a `--postgres` run produces no tables, reinstall the extra:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
pip install "graphifyy[postgres]"
```

For `.sql` files without a database, install the `sql` extra (`tree-sitter-sql`).

## Try it with a SQL file

You can try this without a database. Install the `sql` extra and extract a schema file:

```sql schema.sql theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
CREATE TABLE users (id SERIAL PRIMARY KEY, email TEXT NOT NULL);
CREATE TABLE orders (id SERIAL PRIMARY KEY, user_id INT REFERENCES users(id), total NUMERIC);
CREATE VIEW big_orders AS SELECT o.id, u.email FROM orders o JOIN users u ON u.id = o.user_id WHERE o.total > 100;
```

```text theme={"theme":{"light":"github-light-default","dark":"github-dark-default"}}
$ graphify extract . --code-only
[graphify extract] wrote ./graphify-out/graph.json: 4 nodes, 6 edges, 1 communities

$ graphify explain orders
Node: orders
  Source:    schema.sql L2
Connections (3):
  --> users [references] [EXTRACTED] schema.sql:L2
  <-- schema.sql [contains] [EXTRACTED] schema.sql:L2
  <-- big_orders [reads_from] [EXTRACTED] schema.sql:L3
```

The foreign key appears as a `references` edge, and the view as `reads_from` edges to both tables. Column definitions don't become nodes.

## FAQ

**Does Graphify write to the database?** No. The connection is read-only.

**Can I keep the password out of my shell history?** Yes. Pass `--postgres ""` and set the standard `PG*` environment variables.

## What's next

> **[PR impact](https://docs.graphify.com/open-source/features/pr-impact.md)**
>
> See what a schema change touches.

> **[Multiple repositories](https://docs.graphify.com/open-source/features/multi-repo.md)**
>
> Join a database graph with several services.

> **[Try it in Graphify](https://docs.graphify.com/platform/quickstart.md)**
>
> 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.