A CLI SQL agent that converts natural language to optimized BigQuery SQL using GPT-4
Project description
✦ · ✧ · ✦ · ✧ · ✦ · ✧ · ✦ · ✧ · ✦ · ✧ · ✦ · ✧ · ✦ · ✧
██████╗ █████╗ ████████╗ █████╗ ███╗ ██╗ █████╗ ██╗ ██╗████████╗
██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗████╗ ██║██╔══██╗██║ ██║╚══██╔══╝
██║ ██║███████║ ██║ ███████║██╔██╗ ██║███████║██║ ██║ ██║
██║ ██║██╔══██║ ██║ ██╔══██║██║╚██╗██║██╔══██║██║ ██║ ██║
██████╔╝██║ ██║ ██║ ██║ ██║██║ ╚████║██║ ██║╚██████╔╝ ██║
╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝ ╚═╝ ╚═════╝ ╚═╝
🚀 SQL Explorer v1.0 · Navigating the BigQuery galaxy...
✦ · ✧ · ✦ · ✧ · ✦ · ✧ · ✦ · ✧ · ✦ · ✧ · ✦ · ✧ · ✦ · ✧
Ask questions in plain English. Get optimized BigQuery SQL instantly.
What is Datanaut?
Datanaut is a CLI agent that converts plain English questions into optimized BigQuery SQL using GPT-4. No SQL knowledge required — just ask your question and Datanaut handles schema retrieval, query generation, cost estimation, and execution.
🧑🚀 You: how many sessions were completed yesterday?
🗺️ Retrieving relevant schema...
🤖 Generating SQL with GPT-4...
GPT-4: Counts completed healing sessions for the previous day.
Optimizations: partition pruning, specific column selection
⚗️ Running BigQuery dry run...
╔══════════════════════════════════════════════════════════╗
║ >> MISSION QUERY ║
╠══════════════════════════════════════════════════════════╣
║ SELECT COUNT(*) AS completed_sessions ║
║ FROM `wehealanalysis`.`asia_south1_healing` ║
║ .healing_sessions( ║
║ DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY), ║
║ DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY) ║
║ ) ║
║ WHERE completedTimestamp IS NOT NULL ║
╚══════════════════════════════════════════════════════════╝
✅ Estimated scan: 43.2 MB
🚀 Launch this query? (y/n):
Installation
pip install datanaut
Setup Within Few Minutes
Step 1 — Authenticate with Google Cloud
gcloud auth application-default login
Don't have the Google Cloud SDK? Download it from cloud.google.com/sdk
Step 2 — Set your OpenAI API key
datanaut config --api-key sk-...
This saves your key globally to ~/.datanaut/config.json — you only need to do this once. No .env file needed in every folder.
Don't have an OpenAI API key? Get one at platform.openai.com/api-keys
Step 3 — Launch
datanaut
That's it. Start asking questions.
Commands
| Command | Description |
|---|---|
datanaut |
Start interactive REPL |
datanaut config --api-key sk-... |
Save OpenAI API key globally |
datanaut config |
Show current config status |
datanaut ask "your question" |
One-shot query without entering REPL |
datanaut ask "..." --dry-run |
Generate and validate SQL without executing |
datanaut init |
Scaffold schema.json in current directory |
datanaut test |
Run batch SQL accuracy tests |
datanaut --version |
Print version |
Interactive REPL commands
Once inside the REPL, these special commands are available:
| Type | Action |
|---|---|
history |
Show previous questions and generated SQL |
clear |
Clear conversation memory |
exit |
Quit Datanaut |
Example questions you can ask
Sessions
how many sessions were completed yesterday?
show me total session duration by listener this week
which session types are most popular this month?
what is the average session duration for chat vs call?
Payments & Revenue
total revenue today
show payments by medium for last 7 days
which users made their first payment this week?
what is revenue by UTM campaign this month?
Users
how many new users signed up yesterday?
show me DAU for the last 30 days
which users have been active but never paid?
Listeners
which listeners had the most cancellations last week?
show listener online duration for today
who are the top 10 listeners by session count this month?
Marketing
which ad campaign brought the most users last month?
show revenue per user by ad category this week
what is CTR by marketing channel?
Features
- GPT-4 with function calling — structured, reliable SQL output every time
- BigQuery dry run — validates SQL and estimates cost before execution
- Cost guardrail — automatically rejects queries that would scan more than 5 GB
- Self-correcting retry — passes BigQuery errors back to GPT-4 for auto-fix (up to 3 attempts)
- Conversation memory — refine queries across turns ("now filter by last 7 days", "add region breakdown")
- Result cache — identical queries skip BigQuery entirely, zero cost
- Datanaut theme — space explorer animations, syntax-highlighted SQL, color-coded cost badges
How it works
Your question
│
▼
Schema retrieval ──── Finds the most relevant table functions from schema.json
│
▼
GPT-4 generation ──── Injects schema + BigQuery rules + your question
│
▼
Dry run ────────────── Validates SQL, estimates bytes scanned, checks cost limit
│
▼
Your confirmation ──── Shows you the SQL and cost before running
│
▼
BigQuery execution ─── Streams results back to your terminal
Requirements
| Requirement | Version |
|---|---|
| Python | 3.10+ |
| Google Cloud SDK | Latest |
| GCP access | BigQuery read permissions on wehealanalysis |
| OpenAI API key | Any GPT-4 enabled key |
Troubleshooting
ModuleNotFoundError: No module named 'datanaut'
pip install --upgrade datanaut
google.auth.exceptions.DefaultCredentialsError
gcloud auth application-default login
OPENAI_API_KEY is not set
datanaut config --api-key sk-...
Query exceeds 5 GB scan limit Add a tighter date range to your question:
instead of: "show all sessions"
ask: "show sessions from last 7 days"
License
MIT © 2024 WeHeal
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datanaut-0.1.2.tar.gz.
File metadata
- Download URL: datanaut-0.1.2.tar.gz
- Upload date:
- Size: 27.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f746afb4eafe43882560756d8d4ed78d0871b865f9be3957180551c04747322
|
|
| MD5 |
f03f1be13470df2725d8aff383ff0670
|
|
| BLAKE2b-256 |
c7909908913c7c88acf0ca6374ccc652babbeebf381947c381d381bf27c6695f
|
File details
Details for the file datanaut-0.1.2-py3-none-any.whl.
File metadata
- Download URL: datanaut-0.1.2-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28175f38fd8a4c1322b4d1a7b5787ca1b52d5093d72272732f9278d08a7c9dbb
|
|
| MD5 |
7e0e246a738e0813ddbd3a3a31d2035d
|
|
| BLAKE2b-256 |
9f94690ccb2dd73d2656b0be19ecd2f7325dfe25ef8c77cc4ae01d29461fc63e
|