Skip to content

Universal database explorer with visual query tools and dashboards. Cross-platform GUI built with PyQt5 and Python.

License

Notifications You must be signed in to change notification settings

BaseMax/qt-db-explorer

Repository files navigation

Qt Database Explorer

Universal database explorer with visual query tools and dashboards. Cross-platform GUI built with PyQt5 and Python.

Features

  • Multi-Database Support: Connect to SQLite, PostgreSQL, and MySQL databases
  • Schema Browser: Explore database structure including tables, columns, indexes, and foreign keys
  • Visual Query Builder: Build SQL queries visually with drag-and-drop interface
  • SQL Editor: Write and execute raw SQL with syntax highlighting
  • Result Tables: View query results in sortable, filterable tables
  • Data Visualization: Create charts (bar, line, pie, scatter) from query results
  • Export Tools: Export data to CSV, JSON, and Excel formats
  • Modular Architecture: Easy to extend with new database drivers

Screenshots

The application provides a professional Qt-based interface with:

  • Left panel: Database schema tree view
  • Right panel: Tabbed interface for SQL editor, query builder, results, and charts
  • Toolbar: Quick access to common operations
  • Status bar: Connection status and query feedback

Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Install Dependencies

pip install -r requirements.txt

Or install manually:

pip install PyQt5 psycopg2-binary PyMySQL matplotlib pandas openpyxl Pygments

Install Package

pip install -e .

Usage

Running the Application

# Using the launcher script
python run.py

# Or using the installed command
qt-db-explorer

# Or running the module directly
python -m db_explorer.main

Connecting to a Database

  1. Click File > Connect or use the toolbar button
  2. Select database type (SQLite, PostgreSQL, or MySQL)
  3. Enter connection parameters:
    • SQLite: Browse for database file
    • PostgreSQL/MySQL: Enter host, port, database, username, and password
  4. Click Test Connection to verify settings
  5. Click Connect to establish connection

Browsing Schema

  • The left panel displays the database schema tree
  • Expand databases to view tables
  • Expand tables to view columns, indexes, and foreign keys
  • Double-click a table to browse its data
  • Right-click for context menu options

Using the SQL Editor

  1. Switch to the SQL Editor tab
  2. Type or paste your SQL query
  3. Click Execute Query or press F5
  4. Results appear in the Results tab

Using the Query Builder

  1. Switch to the Query Builder tab
  2. Select a table from the dropdown
  3. Select columns to include in the query
  4. Add WHERE conditions as needed
  5. Configure ORDER BY and LIMIT
  6. Click Generate SQL to create the query
  7. The query is displayed in the SQL Editor

Viewing Results

  • Results appear in a sortable table
  • Click column headers to sort
  • Use export buttons to save data:
    • Export CSV: Save as comma-separated values
    • Export JSON: Save as JSON array
    • Export Excel: Save as Excel workbook

Creating Charts

  1. Execute a query to get data
  2. Switch to the Charts tab
  3. Click Create Chart
  4. Configure chart options:
    • Chart type (bar, line, pie, scatter)
    • X-axis column
    • Y-axis column
  5. The chart is displayed with zoom and pan controls

Database Drivers

The application uses a modular driver architecture. Each database type has its own driver class:

  • SQLiteDriver: For SQLite databases
  • PostgreSQLDriver: For PostgreSQL databases
  • MySQLDriver: For MySQL/MariaDB databases

Adding New Drivers

To add support for a new database:

  1. Create a new driver class in db_explorer/drivers/
  2. Extend the DatabaseDriver base class
  3. Implement all abstract methods
  4. Register the driver in db_explorer/drivers/__init__.py
  5. Update the connection dialog to support the new type

Project Structure

qt-db-explorer/
├── db_explorer/              # Main package
│   ├── __init__.py
│   ├── main.py              # Application entry point
│   ├── main_window.py       # Main window implementation
│   ├── drivers/             # Database drivers
│   │   ├── __init__.py
│   │   ├── base_driver.py   # Abstract base class
│   │   ├── sqlite_driver.py
│   │   ├── postgresql_driver.py
│   │   └── mysql_driver.py
│   └── widgets/             # UI widgets
│       ├── __init__.py
│       ├── connection_dialog.py
│       ├── schema_browser.py
│       ├── sql_editor.py
│       ├── result_table.py
│       ├── query_builder.py
│       └── chart_widget.py
├── requirements.txt         # Python dependencies
├── setup.py                # Package setup
├── run.py                  # Launcher script
└── README.md               # This file

Dependencies

  • PyQt5: Qt GUI framework for Python
  • psycopg2-binary: PostgreSQL database adapter
  • PyMySQL: MySQL database adapter
  • matplotlib: Plotting library for charts
  • pandas: Data manipulation (optional, for advanced features)
  • openpyxl: Excel file support
  • Pygments: Syntax highlighting (optional enhancement)

Configuration

The application stores connection history and preferences in the Qt settings system. No manual configuration is required.

Security Notes

  • Database passwords are not stored persistently
  • Use read-only database accounts when exploring production databases
  • Be careful with UPDATE, DELETE, and DROP statements
  • The application commits changes immediately - there's no "preview mode"

Troubleshooting

Cannot connect to PostgreSQL/MySQL

  • Verify the database server is running
  • Check firewall settings allow connections
  • Confirm username and password are correct
  • Ensure the database exists

SQLite file not found

  • Verify the file path is correct
  • Check file permissions
  • For new databases, create an empty file first

Charts not displaying

  • Ensure matplotlib is installed correctly
  • Verify the data columns contain numeric values
  • Try a different chart type

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

Author

BaseMax

Version

1.0.0

About

Universal database explorer with visual query tools and dashboards. Cross-platform GUI built with PyQt5 and Python.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages