Connect ChatGPT to a SQL database

Install the AI2SQL app from the ChatGPT plugin directory, sign in with your AI2SQL account, and ChatGPT can answer questions from your real data. Read-only, logged and revocable.

People ask ChatGPT to write SQL and then wish it could just run the query against their actual data. With the AI2SQL app it can, without giving a general-purpose assistant unrestricted access to a database that matters.

Set it up in 3 steps

  1. Install AI2SQL in ChatGPT. Open the AI2SQL app in the ChatGPT plugin directory and add it.
  2. Sign in. ChatGPT opens AI2SQL; sign in (or create an account) and press Allow.
  3. Ask a question. Start with the sample store: "Use AI2SQL to show the top 5 customers by revenue in demo_shop."

To use your own data, connect a PostgreSQL, MySQL or SQL Server database in the AI2SQL dashboard. It shows up in ChatGPT on the next question. Credentials are encrypted and stay on the AI2SQL server.

What ChatGPT can do through AI2SQL

What ChatGPT can't do through AI2SQL

Adding it by hand in developer mode

If you prefer to add the server yourself, turn on developer mode in ChatGPT's connector settings, create a connector with the URL https://builder.ai2sql.io/api/chatgpt-mcp and OAuth authentication, and sign in to AI2SQL when ChatGPT asks.

Why a gateway instead of a direct connection

A chat assistant is exactly the case where you don't want a raw database connection: its output can be confidently wrong, and a chat makes it easy to run a query nobody reviewed. Read-only enforcement, bounded results and an audit trail make "connect ChatGPT to my database" a safe idea. More in is it safe to connect AI to your production database?

Running queries on your own database is part of the Pro and Team plans, which start with a 7-day trial. demo_shop works on every plan. The same server also works from Claude, Cursor, Gemini CLI and n8n.

Frequently asked

Can ChatGPT connect to a SQL database? +

Yes. Install the AI2SQL app from the ChatGPT plugin directory and sign in with your AI2SQL account. ChatGPT can then describe your schema and run read-only SQL on PostgreSQL, MySQL or SQL Server connections you set up in AI2SQL.

Can I try it without connecting my own database? +

Yes. AI2SQL in ChatGPT includes demo_shop, a shared sample store with fake customers, orders and products. Ask: Use AI2SQL to show the top 5 customers by revenue in demo_shop.

Is it safe to connect ChatGPT to my database? +

Through AI2SQL, ChatGPT can only run one SELECT or WITH statement per call; writes and DDL are blocked before they reach the database, results are capped at 1,000 rows, and every call is logged in Agent activity. ChatGPT holds a sign-in token you can revoke, never your database password.

Do I need ChatGPT developer mode? +

No. AI2SQL is installed from the ChatGPT plugin directory. Developer mode is only needed if you want to add the server URL by hand.

Which databases are supported? +

PostgreSQL, MySQL and SQL Server support live schema reads and queries.

Give your agent a database it can't break

Connect a database, grab a key, paste one config. Read-only, logged and revocable from the first query.

Start free →

Related guides