A comprehensive database management system with SQL and multiple database support.
- Multiple Database Support: MySQL, PostgreSQL, SQLite
- Real-time Query Execution: Run SQL queries with live results
- Database Schema Inspection: View tables, columns, and relationships
- Connection Management: Easy database connection setup
- SQL Editor: Write and execute custom SQL queries
- Query Builder: Visual query construction interface
- Query History: Track and reuse previous queries
- Syntax Highlighting: Enhanced SQL code editing
- Data Import: CSV and JSON file import with automatic table creation
- Data Export: Export query results to CSV/JSON formats
- Data Visualization: Charts and graphs with Chart.js
- Bulk Operations: Handle large datasets efficiently
- Secure Authentication: JWT-based login system
- User Registration: Multi-user support with role management
- Session Management: Secure token-based sessions
- Password Security: Bcrypt password hashing
- Modern Design: Clean, responsive interface
- Dark/Light Theme: Multiple theme options
- Mobile Responsive: Works on all devices
- Real-time Updates: Live data refresh
- FastAPI: Modern, fast web framework for APIs
- SQLite: Default database for user management
- PyMySQL: MySQL database connector
- psycopg2: PostgreSQL database connector
- JWT: JSON Web Tokens for authentication
- bcrypt: Password hashing
- pandas: Data manipulation and analysis
- HTML5: Semantic markup
- CSS3: Modern styling with animations
- JavaScript (ES6+): Modern JavaScript features
- Chart.js: Data visualization library
- Font Awesome: Icon library
- Responsive Design: Mobile-first approach
- SQLite: Lightweight, file-based database
- MySQL: Popular relational database
- PostgreSQL: Advanced open-source database
- Python 3.8+: Backend runtime environment
- pip: Python package manager
- Modern Web Browser: Chrome, Firefox, Safari, or Edge
- Internet Connection: For package installation
git clone https://github.com/rskworld/sql-database-manager.git
cd sql-database-manager# Navigate to backend directory
cd backend
# Install Python dependencies
pip install -r requirements.txt
# Start the FastAPI server
uvicorn main:app --reload
# The backend will be available at http://localhost:8000# Navigate to frontend directory
cd frontend
# No build process required - just open the HTML file
# Option 1: Double-click index.html
# Option 2: Use a live server for better development- Frontend: Open
frontend/index.htmlin your browser - Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Username:
admin - Password:
admin123
- Select Database Type: Choose from SQLite, MySQL, or PostgreSQL
- Configure Connection: Enter connection details
- Test Connection: Verify database connectivity
- Save Connection: Store connection for later use
- Write SQL Query: Use the SQL editor or query builder
- Execute Query: Click "Run Query" to execute
- View Results: Results display in a formatted table
- Export Results: Save results to CSV or JSON
- Select File: Choose CSV or JSON file
- Configure Import: Set table name and options
- Import Data: Automatic table creation and data insertion
- Verify Import: Check imported data quality
- Select Data: Choose table or write query
- Choose Format: CSV or JSON export
- Export Data: Download file with results
- Verify Export: Check exported file integrity
- Select Data Source: Table or custom query
- Choose Chart Type: Bar, line, pie, or scatter chart
- Configure Chart: Set labels, colors, and options
- Generate Chart: Interactive visualization
sql-database-manager/
βββ backend/ # FastAPI backend
β βββ main.py # Main application file
β βββ auth.py # Authentication logic
β βββ database.py # Database operations
β βββ models.py # Pydantic models
β βββ query_builder.py # SQL query builder
β βββ data_io.py # Data import/export
β βββ users.py # User management
β βββ config.py # Configuration
β βββ utils.py # Utility functions
β βββ requirements.txt # Python dependencies
βββ frontend/ # Web frontend
β βββ index.html # Main application page
β βββ login.html # User login page
β βββ register.html # User registration page
β βββ style.css # Application styles
β βββ script.js # Main JavaScript logic
β βββ auth.js # Authentication handling
β βββ query_builder.js # Query builder interface
β βββ data_io.js # Data import/export UI
β βββ visualization.js # Chart generation
βββ assets/ # Static assets
βββ docs/ # Documentation
βββ LICENSE # License file
βββ README.md # This file
Edit backend/config.py to modify database connections:
DB_CONFIGS = {
"mysql": {
"host": "localhost",
"port": 3306,
"user": "root",
"password": "",
},
"postgresql": {
"host": "localhost",
"port": 5432,
"user": "postgres",
"password": "",
},
"sqlite": {
"db_path": "mydatabase.db"
}
}Modify frontend/script.js to change API endpoints:
const API_BASE_URL = 'http://localhost:8000';# Test API endpoints
curl http://localhost:8000/test
# Test authentication
curl -X POST "http://localhost:8000/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=admin&password=admin123"
# Test query execution
curl -X POST "http://localhost:8000/query" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query":"SELECT 1","db_type":"sqlite","db_config":{}}'- Open browser developer tools
- Test all UI components
- Verify API calls in network tab
- Check console for errors
# Backend
uvicorn main:app --host 0.0.0.0 --port 8000
# Frontend (serve with any web server)
python -m http.server 3000 --directory frontend# Backend with Gunicorn
pip install gunicorn
gunicorn -w 4 -k uvicorn.workers.UvicornWorker main:app
# Frontend with Nginx (configure nginx to serve frontend files)# Dockerfile
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]- 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
POST /token- Get access tokenPOST /users/- Register new userGET /users/me/- Get current user info
POST /connect- Test database connectionGET /schema/{db_type}- Get database schemaPOST /query- Execute SQL queryPOST /build-query- Build SQL query
POST /import-data- Import data from filePOST /export-data- Export data to filePOST /create-sample-data- Create sample database
- Port 8000 in use: Change port with
--port 8001 - Module not found: Run
pip install -r requirements.txt - Database connection failed: Check database credentials
- CORS errors: Backend CORS configuration
- API calls failing: Check backend is running
- Authentication errors: Verify login credentials
- SQLite file not found: Check file permissions
- MySQL connection failed: Verify MySQL service
- PostgreSQL connection failed: Check PostgreSQL service
Enable debug logging:
# In main.py
import logging
logging.basicConfig(level=logging.DEBUG)- Use indexes for large tables
- Limit result sets with pagination
- Optimize SQL queries
- Enable connection pooling
- Use caching for frequent queries
- Optimize frontend JavaScript
- JWT tokens with expiration
- Secure password hashing
- CORS protection
- SQL injection prevention
- Input validation
- Parameterized queries
- Secure file uploads
- Rate limiting
- Advanced query builder
- Database migration tools
- Query optimization suggestions
- Dark theme support
- Multi-database transactions
- Advanced data visualization
- Query scheduling
- API rate limiting
- Author: RSK World
- Website: https://rskworld.in
- Email: help@rskworld.in
- GitHub: https://github.com/rskworld/sql-database-manager
- API Docs: http://localhost:8000/docs
- User Guide: See Usage section above
- Developer Guide: See Project Structure
- FastAPI: For the excellent web framework
- Chart.js: For data visualization capabilities
- Font Awesome: For beautiful icons
- Open Source Community: For inspiration and contributions
This project is licensed under the MIT License - see the LICENSE file for details.
β If this project helped you, please give it a star!
π Found a bug? Please report it on GitHub Issues
π‘ Have a suggestion? Please open an Issue