DBMD: SQL Preview for VS Code

Execute SQL queries and preview results directly in markdown files with support for SQLite and DuckDB databases.

✨ Features
- 🎯 Native Markdown Preview Integration - Results appear inline with
Cmd+Shift+V / Ctrl+Shift+V
- 🗂️ Dual Database Support - Works with both SQLite and DuckDB
- 🔄 Live Updates - Auto-refresh on document changes
- 📊 HTML Table Rendering - Beautiful, styled result tables
- 🎨 Theme-Aware - Adapts to VS Code light/dark themes
- ⚡ Custom Preview Panel - Side-by-side view with dedicated UI
- 🔧 Configurable - Hide/show queries, set default database types
- 🌍 Cross-Platform - Windows, macOS, and Linux support
📦 Installation
From VS Code Marketplace
- Open VS Code
- Press
Ctrl+Shift+X / Cmd+Shift+X
- Search for "DBMD"
- Click Install
From VSIX File
code --install-extension dbmd-1.0.9.vsix
Prerequisites
- VS Code: 1.85.0 or higher
- SQLite CLI: Pre-installed on most systems
- DuckDB CLI (optional): See installation
🚀 Quick Start
1. Create a Markdown File
Create analysis.md:
---
database: ./data.db
dbType: sqlite
showQuery: false
---
# Sales Analysis
## Top Products
```sql
SELECT product_name, SUM(revenue) as total_revenue
FROM sales
GROUP BY product_name
ORDER BY total_revenue DESC
LIMIT 5;
```
2. Preview Results
Native Preview: Press Cmd+Shift+V (macOS) or Ctrl+Shift+V (Windows/Linux)
Custom Panel: Cmd+Shift+P → "DBMD: Preview Database Query"
📖 Usage
Frontmatter Configuration
database: ./path/to/database.db # Path to database file
dbType: sqlite # 'sqlite' or 'duckdb'
showQuery: false # Show/hide SQL query in output
Path Examples
Relative Paths (Recommended)
database: ./mydata.db # Same directory
database: ./data/mydata.db # Subdirectory
database: ../shared/mydata.db # Parent directory
Absolute Paths
# Windows (use forward slashes)
database: C:/Users/Name/data.db
# macOS/Linux
database: /Users/name/data.db
database: /home/user/data.db
SQL Code Blocks
```sql
SELECT * FROM users WHERE active = 1;
```
Multiple queries per document supported - each renders separately.
⚙️ Configuration
| Setting |
Description |
Default |
dbmd.defaultDatabaseType |
Default database type |
sqlite |
Access via: File → Preferences → Settings → Search "DBMD"
📚 Examples
The examples/ directory contains Chinook database examples (industry-standard music store with 11 tables, 275 albums, 3,503 tracks).
SQLite (chinook_example.md): Sales analysis, customer insights, aggregations
DuckDB (chinook_duckdb_example.md): Window functions, statistical analysis, time-series
Try it: Press F5 → Open example file → Cmd+Shift+V
| Platform |
SQLite |
DuckDB |
| Windows |
✅ Pre-installed |
⚡ Optional |
| macOS |
✅ Pre-installed |
⚡ Optional |
| Linux |
✅ Usually included |
⚡ Optional |
Installing DuckDB (Optional)
# Windows
winget install DuckDB.cli
# macOS
brew install duckdb
# Linux
sudo apt install duckdb
🔧 Development
git clone https://github.com/ivishalgandhi/dbmd.git
cd dbmd
npm install
# Test: Press F5 in VS Code to launch Extension Development Host
🐛 Troubleshooting
Database File Not Found
→ Use forward slashes in paths: C:/path/to/db
→ Save markdown file before previewing
Tables Not Rendering
→ Reload window: Cmd+R / Ctrl+R
→ Check Developer Console: Help → Toggle Developer Tools
→ Verify CLI: sqlite3 --version, duckdb --version
CLI Tool Not Found
→ Install SQLite/DuckDB (see Platform Support)
📜 License
MIT License - see LICENSE
🙏 Acknowledgments
Issues: GitHub | Marketplace: VS Code Marketplace