A comprehensive web-based SQL workbench that simulates a MySQL database environment entirely in the frontend. Users can create databases, tables, execute SQL queries, and perform all CRUD operations without requiring any backend infrastructure.
- Complete Database Simulation: Full MySQL-compatible database environment running in your browser
- Advanced SQL Editor: Professional code editor with syntax highlighting, auto-completion, and formatting
- Real-time Query Execution: Execute SQL queries instantly with realistic response times
- Database Explorer: Interactive sidebar to browse databases, tables, and schemas
- Query History: Track and manage your SQL query history
- Results Visualization: Professional data grids with export functionality
- Database Management: CREATE/DROP/USE DATABASE, SHOW DATABASES
- Table Operations: CREATE/DROP/ALTER TABLE, SHOW TABLES, DESCRIBE
- Data Manipulation: INSERT, SELECT, UPDATE, DELETE
- Advanced Queries: JOIN operations, GROUP BY, ORDER BY, WHERE clauses
- Data Types: INT, VARCHAR, TEXT, DECIMAL, DATE, DATETIME, BOOLEAN
- Constraints: PRIMARY KEY, FOREIGN KEY, NOT NULL, UNIQUE
- Responsive Design: Works perfectly on desktop, tablet, and mobile devices
- Material-UI Interface: Modern, intuitive interface following Material Design principles
- Query Templates: Pre-built query examples for learning and reference
- Error Handling: Clear, actionable error messages
- Keyboard Shortcuts: Efficient workflow with keyboard shortcuts
- Export Options: Download query results as CSV or JSON
- Frontend Framework: React 19.1.1
- Build Tool: Vite 7.1.3
- UI Library: Material-UI (MUI) with complete component set
- Code Editor: Monaco Editor (VS Code editor)
- Routing: React Router DOM
- State Management: React Context API with useReducer
- Data Grid: MUI X Data Grid
- SQL Engine: Custom in-memory SQL parser and executor
-
Clone the repository:
git clone <repository-url> cd sqlhub
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
-
Open your browser: Navigate to
http://localhost:5173
- Open the SQL Workbench by clicking "Open Workbench" from the landing page
- The application comes with pre-loaded sample databases (
employee_dbandecommerce_db) - Use the database explorer on the left to browse tables and schemas
- Try the sample queries in the SQL editor or use the Templates feature
-- Show all databases
SHOW DATABASES;
-- Select a database
USE employee_db;
-- Show tables in current database
SHOW TABLES;
-- View table structure
DESCRIBE employees;
-- Select all data
SELECT * FROM employees;-- Select with conditions
SELECT name, email, department
FROM employees
WHERE department = 'Engineering';
-- Insert new record
INSERT INTO employees VALUES
(6, 'Alice Johnson', 'alice@company.com', 'Engineering', 78000.00, '2023-01-15');
-- Update records
UPDATE employees
SET salary = 85000
WHERE name = 'John Doe';
-- Delete records
DELETE FROM employees
WHERE id = 6;-- Group by with aggregates
SELECT department,
COUNT(*) as employee_count,
AVG(salary) as avg_salary
FROM employees
GROUP BY department;
-- Join tables
SELECT e.name, e.email, d.name as department_name
FROM employees e
JOIN departments d ON e.department = d.name;
-- Subquery
SELECT name, salary
FROM employees
WHERE salary > (SELECT AVG(salary) FROM employees);src/
βββ components/ # Reusable UI components
β βββ DatabaseExplorer.jsx
β βββ SQLEditor.jsx
β βββ ResultsPanel.jsx
β βββ QueryHistory.jsx
β βββ Header.jsx
β βββ LoadingSpinner.jsx
β βββ ErrorBoundary.jsx
β βββ QueryTemplatesDialog.jsx
βββ contexts/ # React Context providers
β βββ SQLContext.jsx
βββ pages/ # Main application pages
β βββ LandingPage.jsx
β βββ WorkbenchPage.jsx
βββ utils/ # Utility functions and classes
β βββ SQLEngine.js
β βββ queryTemplates.js
βββ theme.js # Material-UI theme configuration
βββ App.jsx # Main application component
βββ main.jsx # Application entry point
βββ index.css # Global styles
The heart of the application - a custom SQL parser and executor that:
- Parses SQL commands and validates syntax
- Manages in-memory database state
- Executes queries and returns results
- Handles error cases with descriptive messages
Interactive sidebar component that:
- Displays database hierarchy
- Shows table schemas and column information
- Provides quick actions for database operations
- Supports database and table creation/deletion
Professional code editor featuring:
- Syntax highlighting for SQL
- Auto-completion for keywords and commands
- Multi-query support
- Keyboard shortcuts (Ctrl+Enter to run, Ctrl+Shift+F to format)
- Query templates integration
Comprehensive results display with:
- Tabular view with pagination
- Advanced data grid with sorting and filtering
- Export functionality (CSV, JSON)
- Query execution metrics
- Error message display
The application uses Material-UI's theming system. Customize colors, typography, and component styles in src/theme.js.
Extend the query templates in src/utils/queryTemplates.js to add new categories or examples.
Modify the sample data in SQLEngine.js constructor to change the pre-loaded databases and tables.
The application is fully responsive and adapts to different screen sizes:
- Desktop (1200px+): Full three-panel layout with permanent sidebars
- Tablet (768px-1199px): Collapsible sidebars with overlay
- Mobile (320px-767px): Single-panel view with navigation drawer
- Chrome (recommended)
- Firefox
- Safari
- Edge
The application requires a modern browser with ES2020+ support.
npm run buildnpm run previewThe built application is fully static and can be deployed to any static hosting service like:
- Vercel
- Netlify
- GitHub Pages
- AWS S3
- Firebase Hosting
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with React
- UI components from Material-UI
- Code editor powered by Monaco Editor
- Icons from Material Icons
If you encounter any issues or have questions:
- Check the existing issues in the repository
- Create a new issue with detailed description
- Include browser information and steps to reproduce
Made with β€οΈ for the SQL learning community+ Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the TS template for information on how to integrate TypeScript and typescript-eslint in your project.