Skip to content

dev-asterix/PgStudio

Repository files navigation

🐘 PgStudio

Professional Database Management for VS Code

Version Downloads Rating Status

PgStudio (formerly YAPE) is a comprehensive PostgreSQL database management extension featuring interactive SQL notebooks, real-time monitoring dashboard, AI-powered assistance, and advanced database operationsβ€”all within VS Code.

πŸ“– Documentation β€’ πŸ›’ Marketplace β€’ 🀝 Contributing


πŸ“Ί Video Guides

1. Setup

PgStudio Setup

2. Database Explorer

Database Explorer

3. AI Assistant Setup

AI Assistant Setup

4. AI Assistant Usage

AI Assistant Usage


✨ Key Features

  • πŸ”Œ Secure Connections β€” VS Code SecretStorage encryption
  • πŸ“Š Live Dashboard β€” Real-time metrics & query monitoring
  • πŸ““ SQL Notebooks β€” Interactive notebooks with AI assistance
  • 🌳 Database Explorer β€” Browse tables, views, functions, types, FDWs
  • πŸ› οΈ Object Operations β€” CRUD, scripts, VACUUM, ANALYZE, REINDEX
  • 🌍 Foreign Data Wrappers β€” Manage foreign servers, user mappings & tables
  • πŸ€– AI-Powered β€” Generate, Optimize, Explain & Analyze (OpenAI, Anthropic, Gemini)
  • πŸ“€ Export Data β€” Export results to CSV, JSON, or Excel

🎯 Why PgStudio?

🎨 Modern Interface

  • Beautiful, intuitive UI designed for developers
  • Real-time dashboard with live metrics
  • Context-aware operations
  • Seamless VS Code integration

⚑ Powerful Features

  • Interactive SQL notebooks
  • πŸ€– AI-powered Copilot & agentic support
  • Advanced query management
  • Complete CRUD operations

πŸš€ Quick Start

# Install from VS Code
ext install ric-v.postgres-explorer

# Or via command line
code --install-extension ric-v.postgres-explorer

Then: PostgreSQL icon β†’ Add Connection β†’ Enter details β†’ Connect!


πŸ—οΈ Project Structure

yape/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ extension.ts          # Extension entry point
β”‚   β”œβ”€β”€ commands/             # Command implementations
β”‚   β”‚   β”œβ”€β”€ tables.ts         # Table operations
β”‚   β”‚   β”œβ”€β”€ views.ts          # View operations
β”‚   β”‚   β”œβ”€β”€ functions.ts      # Function operations
β”‚   β”‚   β”œβ”€β”€ connection.ts     # Connection commands
β”‚   β”‚   β”œβ”€β”€ notebook.ts       # Notebook commands
β”‚   β”‚   β”œβ”€β”€ helper.ts         # Shared helper utilities
β”‚   β”‚   β”œβ”€β”€ sql/              # SQL template modules
β”‚   β”‚   β”‚   β”œβ”€β”€ tables.ts     # Table SQL templates
β”‚   β”‚   β”‚   β”œβ”€β”€ views.ts      # View SQL templates
β”‚   β”‚   β”‚   β”œβ”€β”€ functions.ts  # Function SQL templates
β”‚   β”‚   β”‚   β”œβ”€β”€ indexes.ts    # Index SQL templates
β”‚   β”‚   β”‚   └── ...           # Other SQL templates
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ providers/            # VS Code providers
β”‚   β”‚   β”œβ”€β”€ DatabaseTreeProvider.ts   # Tree view provider
β”‚   β”‚   β”œβ”€β”€ NotebookKernel.ts         # Notebook kernel
β”‚   β”‚   β”œβ”€β”€ ChatViewProvider.ts       # AI chat provider
β”‚   β”‚   β”œβ”€β”€ SqlCompletionProvider.ts  # IntelliSense
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ services/             # Business logic
β”‚   β”‚   β”œβ”€β”€ ConnectionManager.ts      # Connection handling
β”‚   β”‚   └── SecretStorageService.ts   # Credential storage
β”‚   β”œβ”€β”€ dashboard/            # Dashboard webview
β”‚   β”œβ”€β”€ common/               # Shared utilities
β”‚   └── test/                 # Unit tests
β”œβ”€β”€ resources/                # Icons & screenshots
β”œβ”€β”€ docs/                     # Documentation & landing page
β”œβ”€β”€ dist/                     # Compiled output (bundled)
β”œβ”€β”€ out/                      # Compiled output (tsc)
β”œβ”€β”€ package.json              # Extension manifest
β”œβ”€β”€ tsconfig.json             # TypeScript config
└── webpack.config.js         # Webpack config

πŸ€– AI-Powered Operations

PgStudio integrates advanced AI capabilities directly into your workflow, but keeps YOU in control.

πŸͺ„ Generate Query (Natural Language β†’ SQL)

Describe what you need in plain English (e.g., "Show me top 10 users by order count"), and PgStudio will generate the SQL for you using your schema context.

  • Command Palette: AI: Generate Query
  • Context-Aware: The AI understands your table schemas, columns, and relationships.

⚑ Performance Optimization

Click the Optimize button on any successful query result.

  • Explain Scripts: Generates EXPLAIN ANALYZE commands for deeper profiling.
  • Static Analysis: Suggests missing indexes, query rewrites, or schema improvements.

πŸ“Š Data Analysis

Click the Analyze Data button in result tables.

  • Clean Workflow: Automatically exports data to a temporary CSV and attaches it to the chat.
  • Actionable Insights: AI summarizes patterns, trends, and outliers in your result sets.

✨ Error Handling (Explain & Fix)

When a query fails, get instant help directly in the error cell.

  • Explain Error: Translates cryptic Postgres errors into plain English.
  • Fix Query: Suggests corrected SQL to resolve the error.

πŸ›‘οΈ Safe Execution Model (Notebook-First)

We believe AI should assist, not take over. No query is ever executed automatically.

  1. Ask/Trigger: You use one of the AI features.
  2. Review: The AI generates SQL or suggestions in the chat.
  3. Insert: You click "Open in Notebook" to place code into a cell.
  4. Execute: You review the code and click "Run" when you are ready.

πŸ“Š Advanced Visualizations

Turn any query result into beautiful, interactive charts in seconds.

  • One-Click Charting: Instantly visualize your data directly from the notebook results.
  • Customizable: Toggle between Bar, Line, Pie, Doughnut, and Scatter charts.
  • Rich Data Display:
    • Log Scale: Easily analyze data with wide variances.
    • Blur/Glow Effects: Modern, high-fidelity chart aesthetics.
    • Zoom & Pan: Inspect detailed data points interactively.

πŸ› οΈ Local Development

Prerequisites

  • Node.js β‰₯ 18.0.0
  • VS Code β‰₯ 1.90.0
  • PostgreSQL (for testing)

Setup

# Clone the repository
git clone https://github.com/dev-asterix/yape.git
cd yape

# Install dependencies
npm install

# Compile TypeScript
npm run compile

Development Commands

Command Description
npm run watch Watch mode (auto-recompile)
npm run compile One-time TypeScript compilation
npm run esbuild Bundle with esbuild (with sourcemaps)
npm run esbuild-watch Bundle in watch mode
npm run test Run unit tests
npm run coverage Run tests with coverage
npm run vscode:prepublish Build for production

Running the Extension

  1. Open the project in VS Code
  2. Press F5 to launch Extension Development Host
  3. Or use Run and Debug (Ctrl+Shift+D) β†’ "Run Extension"

Debugging Tips

  • Output Panel: Ctrl+Shift+U β†’ Select "PostgreSQL Explorer"
  • DevTools: Ctrl+Shift+I in Extension Development Host
  • Webview Debug: Right-click in webview β†’ "Inspect"

πŸ§ͺ Testing

# Run all tests
npm run test

# Run with coverage
npm run coverage

Tests are located in src/test/unit/ using Mocha + Chai + Sinon.


🀝 Contributing

Commit Convention

We follow Conventional Commits:

feat: add new feature
fix: resolve bug
docs: update documentation
refactor: code restructuring
test: add/update tests
chore: maintenance tasks

πŸ“¦ Building & Publishing

# Build VSIX package
npx vsce package

# Publish to VS Code Marketplace
npx vsce publish

# Publish to Open VSX
npx ovsx publish

πŸ“ License

MIT License


Made with ❀️ for the PostgreSQL Community

Made with TypeScript PostgreSQL VS Code

Also on Open VSX


???? Troubleshooting

Connection Issues

SSL Connection Failures

Problem: SSL connection failed or certificate verify failed

Solutions:

  • Disable SSL (development only): Set SSL Mode to disable
  • Use prefer mode (tries SSL, falls back to non-SSL)
  • Provide CA certificate: SSL Mode verify-ca + CA Certificate path

Connection Timeout

Problem: Connection timeout or ETIMEDOUT

Solutions:

  • Increase connection timeout in settings
  • Check firewall rules
  • Verify PostgreSQL pg_hba.conf allows remote connections
  • Ensure PostgreSQL is listening on correct interface

SSH Tunnel Issues

Problem: SSH tunnel failed to establish

Solutions:

  • Verify SSH credentials and host
  • Test SSH connection manually: ssh user@host -p port
  • Check SSH key permissions: chmod 600 ~/.ssh/id_rsa
  • Ensure SSH server allows port forwarding

Performance Issues

Large Result Sets

Problem: Querying large tables causes freezes

Solution: Results are automatically limited to 10,000 rows. Use LIMIT clause for specific row counts.

Slow Tree View

Problem: Database tree takes long to load

Solutions:

  • Use search filter to narrow objects
  • Collapse unused schemas
  • Disable object count badges in settings

Common Error Messages

Error Cause Solution
password authentication failed Wrong credentials Verify username/password
database does not exist Database name typo Check database name
permission denied Insufficient privileges Grant SELECT permission
too many connections Pool exhausted Close unused connections
no pg_hba.conf entry Access control Add entry to pg_hba.conf

πŸ™ˆ Feature Comparison

Feature PgStudio pgAdmin DBeaver TablePlus
VS Code Integration βœ… Native ❌ ❌ ❌
SQL Notebooks βœ… Interactive ❌ ❌ ❌
AI Assistant βœ… Built-in ❌ ❌ ❌
Real-time Dashboard βœ… βœ… ⚠️ Limited ⚠️ Limited
Inline Cell Editing βœ… βœ… βœ… βœ…
Export Formats CSV, JSON, Excel CSV, JSON CSV, JSON, Excel CSV, JSON, SQL
SSH Tunneling βœ… βœ… βœ… βœ…
Foreign Data Wrappers βœ… Full βœ… ⚠️ Limited ❌
License MIT (Free) PostgreSQL (Free) Apache 2.0 (Free) Proprietary (Paid)

Unique to PgStudio

  • πŸ€– AI-powered query generation and optimization
  • πŸ““ Interactive SQL notebooks with persistent state
  • πŸ”„ Infinite scrolling for large result sets (10k rows)
  • 🎨 Modern UI integrated into VS Code
  • πŸš€ Hybrid connection pooling for performance

About

Intelligent PostgreSQL tooling for VS Code | Build, explore, and query Postgres faster

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages