By Source · PostgreSQL

PostgreSQL + Connect AI

Point any AI agent at your application database, OLTP store, or analytical Postgres. Connect AI handles schema search paths, JSON columns, and role-based visibility.

Use with Claude  ·  Use with OpenAI

Common objects
Table View Schema Sequence Function MaterializedView + extensions, custom types
-- Ask Claude Code (or any MCP-aware agent):
--
-- "In PostgreSQL, show me users who placed an order in the
-- last 7 days, with their most recent order total."
--
-- Claude generates and runs this SQL via the queryData MCP tool.
-- Standard PostgreSQL syntax -- JSON, arrays, and CTEs all work.

SELECT
  u.id,
  u.email,
  o.total AS most_recent_total,
  o.created_at
FROM [PostgreSQL].[public].[users] u
JOIN LATERAL (
  SELECT total, created_at
  FROM [PostgreSQL].[public].[orders]
  WHERE user_id = u.id
  ORDER BY created_at DESC
  LIMIT 1
) o ON true
WHERE o.created_at >= NOW() - INTERVAL '7 days'
ORDER BY o.created_at DESC
LIMIT 25

Tutorials by AI surface

Working integrations for PostgreSQL + every supported AI surface.

PostgreSQL + Claude Agent SDK Application database questions, schema exploration, and operational queries with safe read-only access.
PostgreSQL + OpenAI SDK OpenAI Python SDK assistant for ad-hoc analytics, customer support lookups, and incident triage.
PostgreSQL + CrewAI Multi-agent crew for ops dashboards and SLA reports built from live application data.

Known quirks

Schema search path

Postgres looks up unqualified table names against the connection's search_path. Connect AI passes identifiers as fully-qualified [Catalog].[Schema].[Table], so search_path doesn't matter for queries the agent issues, but it does affect any raw SQL you paste from psql.

Case-sensitive quoted identifiers

Postgres folds unquoted identifiers to lowercase but preserves case for quoted ones. A table created as "Users" won't match FROM users. Use getTables to discover the canonical case before writing queries.

JSON and JSONB columns

JSON fields are accessible via -> and ->> operators or jsonb_path_query. Tell the agent the JSON shape in its system prompt, or expose a view that flattens common fields if the data is queried often.

Row-level security

If RLS policies are enabled, the agent only sees rows the connection's role is allowed to read. Connect AI doesn't bypass RLS. Create a least-privilege Postgres role for agent access and rely on RLS for tenant isolation.

Existing tutorials

Long-form recipes from the CData Knowledge Base.

View tutorials
Connect AI documentation

Full API reference, authentication guides, and configuration details.

View docs