---
title: "Connect ChatGPT to Multiple Remote Databases"
slug: connect-chatgpt-to-multiple-databases
date_published: 2025-10-12T10:40:57.252Z
original_url: https://www.tigzig.com/post/connect-chatgpt-to-multiple-databases
source: migrated
processed_at: 2025-12-03T12:30:00.000Z
---

# Connect ChatGPT to Multiple Remote Databases

(Supabase, Neon, Aiven, AWS... doesn't matter)

## The Problem

Databases scattered across providers. Different engines. Different tables.

Users don't care. They just want an answer.

GPT needs to know where to go.

## The Setup (my stack)

1. FastAPI connector - takes SQL, routes to right DB, handles auth.
2. Function calling schema - OpenAPI JSON so GPT knows where to send queries.
3. YAML semantic layer - schema, sample rows, rules, golden queries.
4. Custom instructions - routing rules + answer format.

## How it Runs

1. User asks.
2. GPT picks DB + builds SQL.
3. Query sent to FastAPI.
4. FastAPI checks auth → DB runs query.
5. DB → FastAPI → JSON → GPT replies.

## Try It Live

[ChatGPT Share Link](https://chatgpt.com/share/68ca3b99-724c-800f-b303-8374ed94ba6d)

Works across Supabase (ODI cricket), Neon (T20 cricket), Aiven (Tour de France). Approx. 2.5M rows, 340MB data, 7.5k matches across past approx. 22 years + 122 years of Tour history.

## Security

IT world has been doing it for decades - API keys, read-only roles, rate limits, role based access, row level security etc. Nothing new. Setup as per your requirements. GPT is just another frontend (OAuth enabled by the way)

## Source + Docs

* Docs: [app.tigzig.com/cricket-tour-de-france-gpt](http://app.tigzig.com/cricket-tour-de-france-gpt)
* Repo: [github.com/amararun/shared-fastapi-fixed-databases](https://github.com/amararun/shared-fastapi-fixed-databases/)
* Data: [Google Drive](https://drive.google.com/drive/folders/1QlE8tJDKAX9XaHUCabfflPgRnNiOXigV?usp=drive_link)
