Home > AI

Can ChatGPT query a database?

Using the AI chatbot to automate your database admin
Last Updated on

Reviewed By: Kevin Pocock

Can ChatGPT query a database?
PC Guide is reader-supported. When you buy through links on our site, we may earn an affiliate commission. Read More

ChatGPT, the AI language model from OpenAI, brings artificial intelligence to database management systems. However, ChatGPT’s query capabilities may be limited by the link, or lack thereof, between it and an SQL server instance. Let’s learn how the OpenAI LLM (Large Language Model) can perform SQL queries with natural language inputs. Can ChatGPT query a database?

Can ChatGPT access a database?

No, ChatGPT cannot access a database – not directly, at least.

ChatGPT Plus and ChatGPT Enterprise, the paid subscription tiers for ChatGPT, allow the user to install plugins. Through plugins, the AI language model can interface with other software, and perform tasks on behalf of the humans that ordinarily use it.

Essential AI Tools

Prices and savings subject to change. Click through to get the current deal prices.

Razer DeathStalker V2 Pro Wireless Gaming Keyboard (Renewed)

Low-Profile Optical Switche HyperSpeed Wireless & Bluetooth 5.0-40 Hr Battery – Ultra-Durable Coated Keycaps – Chroma RGB (Renewed)
Save $99 Now!

Samsung Galaxy Watch 4 40mm Smart Watch Bluetooth – Pink Gold (Renewed)

Save 27% Now!

ASUS ROG Rapture WiFi 6E Gaming Router (GT-AXE16000)

Quad-Band, 6 GHz Ready, Dual 10G Ports, 2.5G WAN Port, AiMesh Support, Triple-level Game Acceleration, Lifetime Internet Security, Instant Guard
Save 36% NOW!

Amazon Fire HD 10 tablet

10.1″, 1080p Full HD, 32 GB, latest model (2021 release), Olive
Save 16% Now!

AMD Ryzen 5 5600X 6-core, 12-Thread Unlocked Desktop Processor with Wraith Stealth Cooler

AMD’s fastest 6 core processor for mainstream desktop, with 12 processing threads Can deliver elite 100 plus FPS performance in the world’s most popular games Bundled with the quiet, capable AMD Wraith Stealth cooler. System Memory Type: DDR4 4.6 GHz Max Boost, unlocked for overclocking, 35 MB of cache, DDR-3200 support For the advanced Socket AM4 platform, can support PCIe 4.0 on X570 and B550 motherboards

The ChatGPT plugin selection includes those for data management and data analytics purposes. ChatGPT Excel plugins exist for this very purpose.

Can you connect ChatGPT to a database?

ChatGPT cannot connect to a database by itself. However, with ChatGPT Plus or ChatGPT Enterprise, the AI chatbot can access the internet and any publicly available databases on it. Google Sheets can be used to create publically accessible databases for an AI chatbot, which includes Microsoft Bing Chat and Google Bard.


Deals season is here folks, and with it comes a plethora of eye-catching price cuts on some of the industry's most popular tech. Below are some of the best deals you can find right now.

*Prices and savings subject to change. Click through to get the current prices.


A Google sheets database.
A Google sheets database.

Can ChatGPT query a database?

Yes, ChatGPT can query a database, by using the ChatGPT API (or OpenAPI as its lesser known). The OpenAI API allows the development of custom apps and functionality, powered by the GPT-3.5 Turbo or GPT-4 model.

SQL developers who know a little Python can run real-time analytics and complex queries using human-like text with prompt engineering. Prompt engineering is the art of knowing how to ask for what you want.

How to use ChatGPT to query a database

Data analysts will have a head start here, being that the first step in using ChatGPT to query a database is to know how to query any database. 

Thankfully, AI takes a lot of the technical know-how out of it. You don’t need to be a software engineer to use AI for database management – in truth, you barely need to know SQL syntax or other query languages, but knowing your database schema does help. 

The way ChatGPT works is by taking an input prompt in natural human language and feeding this into its NLP (Natural Language Processing) algorithm. It can then produce a text output – which again, can be in natural human language, or it can be code. SQL (Structured Query Language) is one such example. This behavior can be used for various applications, including generating a MySQL or PostgreSQL script.

However, a ‘broad AI’ or ‘general AI’ like ChatGPT can make mistakes. It’s best to use ChatGPT for guidance, while still using SQL server management studio in conjunction.

About the Author

Steve is an AI Content Writer for PC Guide, writing about all things artificial intelligence. He currently leads the AI reviews on the website.