Follow these steps to get QueryGPT running in minutes!
- Go to Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy your API key
Option A: Using .env file (Recommended)
# Create .env file from template
cp env_template.txt .env
# Edit .env and replace with your actual API key
nano .env # or use any text editorOption B: Export as environment variable
export GEMINI_API_KEY="your_actual_api_key_here"pip3 install -r requirements.txtOption A: Using the startup script (Easiest)
chmod +x start_server.sh
./start_server.shOption B: Manual start
python3 backend/app.pyOpen index.html in your browser:
- macOS:
open index.html - Linux:
xdg-open index.html - Windows: Double-click
index.html
- Check that the connection status shows "✓ Connected to Database"
- Try an example query by clicking on one of the example cards
- Click "Generate & Execute Query"
-
Documentation Status
Show me all farmers with their documentation status by partner -
Recent Plantations
List all kyaris created in the last 30 days with verification status -
Missing Documents
Get all farms with missing land records grouped by district -
Species Analytics
Show plantation model usage with species distribution
- Make sure your API key is set in
.envor as an environment variable - Restart the server after setting the API key
- Check your internet connection
- Verify the database credentials in
backend/app.py - Ensure the database server is accessible
# Try upgrading pip first
pip3 install --upgrade pip
# Then install requirements again
pip3 install -r requirements.txt# Find and kill the process using port 5000
lsof -ti:5000 | xargs kill -9
# Or change the port in backend/app.py (last line)
app.run(debug=True, host='0.0.0.0', port=5001)- ✅ Query any table in the database using natural language
- ✅ Export results as CSV or JSON
- ✅ Copy generated SQL for reuse
- ✅ Filter data by date ranges, partners, locations, etc.
- ✅ Aggregate and analyze data with complex queries
- All queries are read-only (SELECT statements only)
- Dangerous operations (INSERT, UPDATE, DELETE) are blocked
- Uses dedicated read-only database user
- SQL injection protection built-in
The system understands your complete schema including:
- Farmer and farm management
- Plantation and species tracking
- Documentation and media
- Location hierarchy
- Biochar production
- Carbon quantification
- AWD (Alternate Wetting & Drying) projects
- Be specific: "Show farmers in Punjab created last month" works better than "show farmers"
- Use examples: Click example cards to see query patterns
- Check the SQL: Review generated SQL to understand what data you're getting
- Iterate: If results aren't quite right, refine your query and try again
- Check the console (browser DevTools) for frontend errors
- Check terminal for backend errors
- Review the generated SQL to see what query was created
- Try simpler queries first, then build up complexity
Start querying your database with natural language! The AI will help you write complex SQL queries without knowing SQL.
Happy Querying! 🚀