Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>DB CopilotNew to Visual Studio Code? Get it now.
DB Copilot

DB Copilot

InjectionAI

|
6 installs
| (0) | Free
AI-powered SQL query generation and execution directly in VS Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

DB Copilot VS Code Extension

AI-powered SQL query generation and execution directly in VS Code. Ask database questions in natural language and get beautiful, formatted results.

Features

  • 🤖 Natural Language to SQL: Ask questions in plain English, get optimized SQL queries
  • 🔌 Database Connection Management: Easy connect/disconnect with secure credential storage
  • � Auto-Detection: Automatically detects PostgreSQL (port 5432) or MySQL (port 3306)
  • 📊 Beautiful Results Display: View query results in a clean, formatted webview
  • 🌳 Schema Explorer: Browse your database structure in the sidebar
  • 💾 Schema Caching: Caches schema for 5 minutes to improve performance
  • 🔐 Environment Variable Support: Load database credentials from .env file
  • 📝 Query History: Track all your queries and results
  • 🎨 Syntax Highlighting: SQL queries with proper formatting
  • ⚡ Multiple AI Providers: Support for OpenAI, Anthropic, Groq, and Google Gemini

Installation

  1. Install the extension from the VS Code Marketplace
  2. Configure your database connection in settings
  3. Set your AI provider API key in environment variables

Option A: Using .env file (Recommended)

  • Create a .env file in your workspace root:
    DB_HOST=your-database-host.com
    DB_PORT=5432
    DB_NAME=your_database_name
    DB_USER=your_user
    DB_PASSWORD=your_password
    DB_SSL=true
    GROQ_API_KEY=your_api_key_here
    

Option B: Using VS Code Settings

  • Open VS Code Settings (Cmd/Ctrl + ,)
  • Search for "DB Copilot"
  • Set your database host, port, name, and user
  1. Connect to Database
    • Open Command Palette (Cmd/Ctrl + Shift + P)
    • Run "DB Copilot: Connect to Database"
    • Database type will be auto-detected based on port (5432=PostgreSQL, 3306=MySQL)
    • Enter password if not in .env file

3 - Run "DB Copilot: Connect to Database"

  • Enter your database password when prompted
  1. Ask Questions
    • Open Command Palette (auto-detects type)
  • DB Copilot: Disconnect Database - Disconnect from database
  • DB Copilot: View Database Schema - View complete schema in a webview
  • DB Copilot: Clear Schema Cache - Clear cached schema (forces reload on next query)
    • View beautiful results!

CEnvironment Variables (Recommended)

Create a .env file in your workspace:

# Database Configuration
DB_HOST=your-host.com
DB_PORT=5432
DB_NAME=your_database
DB_USER=your_user
DB_PASSWORD=your_password
DB_SSL=true

# AI Provider (choose one)
GROQ_API_KEY=your_api_key
# or OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY

VS Code Settings

Alternatively, configure via VS Code settings:

{
  "dbCopilot.database.host": "your-host.com",
  "dbCopilot.database.port": 5432,
  "dbCopilot.database.name": "your_database",
  "dbCopilot.database.user": "your_user",
  "dbCopilot.database.ssl": true
}

Note: Database dialect is auto-detected:

  • Port 5432 → PostgreSQL
  • Port 3306 → MySQLjson { "dbCopilot.database.dialect": "postgresql", "dbCopilot.database.host": "your-host.com", "dbCopilot.database.port": 5432, "dbCopilot.database.name": "your_database", "dbCopilot.database.user": "your_user", "dbCopilot.database.ssl": true }

### AI Provider Settings

```json
{
  "dbCopilot.llmProvider": "groq",
  "dbCopilot.modelName": "llama-3.3-70b-versatile",
  "dbCopilot.maxQueryLimit": 1000,
  "dbCopilot.enableSafetyCheck": true
}

Supported Databases

  • ✅ PostgreSQL
  • ✅ MySQL
  • 🔜 SQLite (coming soon)
  • 🔜 Microsoft SQL Server (coming soon)

Supported AI Providers

  • Groq (default) - Fast, cost-effective
  • OpenAI - GPT-4, GPT-3.5
  • Anthropic - Claude models
  • Google Gemini - Gemini Pro

Examples

Question: "Show me all users who joined this month"

Generated SQL:

SELECT * FROM users 
WHERE created_at >= DATE_TRUNC('month', CURRENT_DATE)
ORDER BY created_at DESC;

Question: "What are the top 5 products by revenue?"

Generated SQL:

SELECT p.name, SUM(oi.quantity * oi.price) as total_revenue
FROM products p
JOIN order_items oi ON p.id = oi.product_id
GROUP BY p.id, p.name
ORDER BY total_revenue DESC
LIMIT 5;

Security

  • Database passwords are never stored, only requested at connection time
  • API keys are read from environment variables only
  • Sensitive data is not logged or transmitted
  • SSL/TLS support for database connections

Requirements

  • VS Code 1.85.0 or higher
  • Node.js 18+ (for extension development)
  • A supported database (PostgreSQL or MySQL)
  • API key for your chosen AI provider

Known Issues

  • Password re-entry required on each connection (will add secure storage)
  • Limited to SELECT queries for safety (configurable)

Release Notes

1.0.0

Initial release:

  • Natural language to SQL conversion
  • Database connection management
  • Schema explorer
  • Beautiful results display
  • Support for PostgreSQL and MySQL

Contributing

Found a bug or have a feature request? Please open an issue on GitHub.

License

MIT


Enjoy using DB Copilot! 🚀

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft