How to Connect AI to Your PostgreSQL Database
Before You Start
You need a PostgreSQL database that accepts remote connections. This can be a managed instance on AWS RDS, Supabase, Neon, Render, or any provider that gives you a Postgres connection string. You will need the host address, port (usually 5432), database name, username, and password. If your provider gives you a connection string like postgres://user:pass@host:5432/dbname, you can extract each piece from that URL.
The user account you connect with determines what the AI can do. A read-only user limits the AI to SELECT queries, which is the safest option for exploring your data. If you want to edit records through the web UI, the user needs INSERT, UPDATE, and DELETE permissions as well.
Step-by-Step Setup
Log into your admin panel and find the PostgreSQL app in the app directory. Click Install to add it to your account. This creates the settings page where you will configure your database connection.
Open the PostgreSQL app settings and fill in your host, port, database name, username, and password. For AWS RDS, the host is the endpoint URL from your RDS console. For Supabase, Neon, or Render, copy the connection details from your provider's dashboard. Make sure to use the direct connection host, not a pooler address, for the initial setup.
Click the Test Connection button. The platform connects to your PostgreSQL server and confirms the version number if successful. If it fails, check that your provider allows remote connections from external IPs and that the port is open. On AWS RDS, verify the security group inbound rules allow traffic on port 5432.
After a successful connection, the AI reads your entire database schema. It detects all tables, columns, data types, primary keys, foreign keys, constraints, and indexes across all schemas (public and any custom schemas). This schema map is what allows the AI to write accurate queries when you ask questions in plain English. The scan runs once and can be refreshed whenever your schema changes.
Go to the query interface and type a question like "show me the 20 most recent orders with customer names" or "what is the average order value by country for this year." The AI translates your question into a PostgreSQL query, runs it, and displays the results. You can also browse tables in the web UI to view, filter, and edit data visually.
PostgreSQL-Specific Features
The AI SQL assistant understands PostgreSQL-specific syntax and features. It can work with JSONB columns, array types, CTEs (common table expressions), window functions, and full-text search. If your database uses PostgreSQL extensions like PostGIS for geographic data or pg_trgm for fuzzy text matching, the AI recognizes those column types and can write queries that use extension functions.
PostgreSQL's stricter type system also benefits the AI. Because Postgres enforces data types more strictly than MySQL, the AI can make more confident assumptions about what operations are valid on each column, which leads to fewer query errors.
Common Connection Issues
If the connection test fails, the most common causes are firewall rules blocking port 5432, the database not allowing connections from external IPs, or incorrect credentials. On managed providers like Supabase or Neon, make sure you are using the database password (not the dashboard login password) and that the connection is configured for direct access rather than through a connection pooler.
If the connection works but the schema scan returns no tables, check that the connected user has access to the schemas you expect. In PostgreSQL, tables live in schemas (usually public), and the user needs USAGE permission on the schema plus SELECT on the tables.
What You Can Do Next
With your PostgreSQL database connected, explore querying with plain English, finding patterns in your data with AI, or automating database reports. If you are choosing between MySQL and PostgreSQL, see our MySQL vs PostgreSQL comparison.
Connect your PostgreSQL database to AI and start exploring your data in plain English.
Get Started Free