Skip to content

Exotic209093/Database-viewer

Repository files navigation

Database Viewer Pro

A powerful, modern web application for connecting to and viewing multiple database types including SQLite, MySQL, PostgreSQL, MongoDB, and SQL Server with automatic cleanup and JSON export capabilities.

Features

✅ Implemented

Database Support (5 Types)

  • 🗄️ SQLite - Upload database files (.db, .sqlite, .sqlite3) up to 50MB
  • 🐬 MySQL - Connect to remote MySQL databases (v5.7+)
  • 🐘 PostgreSQL - Connect to PostgreSQL databases (v9.6+)
  • 🍃 MongoDB - Connect to MongoDB databases with collection support
  • 🔷 SQL Server - Connect to Microsoft SQL Server (2012+)

Core Features

  • 📋 Universal Table Browser - View tables/collections from any database type
  • 📄 Data Viewer - Browse data with proper formatting and NULL value handling
  • 📄 Pagination - Navigate large datasets efficiently (50 rows per page)
  • 📥 JSON Export - Export any table/collection to JSON format with metadata
  • 🗑️ Auto-Cleanup - Automatic connection cleanup when you close the tab or after 2 hours
  • 🔒 Secure Connections - Session-based isolation with unique session IDs
  • 📱 Responsive Design - Beautiful, modern UI that works on all devices
  • 🎯 Features Tab - Track implemented and planned features

🚀 Planned Features

  • 🔍 Search & Filter - Column-specific filters and full-text search
  • 📊 Data Visualization - Generate charts and graphs from data
  • 🔧 SQL Query Editor - Execute custom SQL queries
  • 📤 Multiple Export Formats - CSV, Excel, XML support
  • 🔗 Relationship Viewer - Visualize foreign key relationships

Installation

Prerequisites

Setup

  1. Install the required dependencies:
pip install -r requirements.txt
  1. Run the application:
python Main.py
  1. Open your browser and navigate to:
http://localhost:5000

Database-Specific Notes

MySQL

  • Ensure your MySQL server allows remote connections if connecting from a different machine
  • Default port: 3306

PostgreSQL

  • Ensure pg_hba.conf allows connections from your IP
  • Default port: 5432

MongoDB

  • Supports both connection strings and individual parameters
  • Default port: 27017
  • For MongoDB Atlas, use the connection string option

SQL Server

  • Requires ODBC Driver 17 for SQL Server to be installed
  • For Windows, download from Microsoft
  • For Linux: sudo apt-get install mssql-tools unixodbc-dev
  • Default port: 1433

Usage

Database Viewer Tab

Connect to a Database

Option 1: SQLite (Upload File)

  1. Select "SQLite" from the database type selector
  2. Click the upload area or drag and drop your database file
  3. Supported formats: .db, .sqlite, .sqlite3 (up to 50MB)

Option 2: MySQL

  1. Select "MySQL" from the database type selector
  2. Enter connection details:
    • Host (e.g., localhost)
    • Port (default: 3306)
    • Database name
    • Username
    • Password
  3. Click "Connect to MySQL"

Option 3: PostgreSQL

  1. Select "PostgreSQL" from the database type selector
  2. Enter connection details:
    • Host (e.g., localhost)
    • Port (default: 5432)
    • Database name
    • Username
    • Password
  3. Click "Connect to PostgreSQL"

Option 4: MongoDB

  1. Select "MongoDB" from the database type selector
  2. Either:
    • Enter a connection string (e.g., mongodb://user:pass@host:port/database)
    • OR fill in individual fields (host, port, database, username, password)
  3. Click "Connect to MongoDB"

Option 5: SQL Server

  1. Select "SQL Server" from the database type selector
  2. Enter connection details:
    • Host (e.g., localhost)
    • Port (default: 1433)
    • Database name
    • Username
    • Password
  3. Click "Connect to SQL Server"

Browse Data

  1. View Tables/Collections:

    • After connecting, all tables (or collections for MongoDB) will be displayed as cards
    • Click on any table card to view its data
  2. Navigate Data:

    • Table data is displayed with pagination (50 rows per page)
    • Use the pagination controls to navigate through large datasets
  3. Export Data:

    • Click the "Export to JSON" button to download the current table as JSON
    • Exported file includes table name, database type, columns, row count, and all data
  4. Disconnect:

    • Click the "Disconnect" button to close the current database connection
    • Connections are also automatically closed when you close the browser tab

Features Tab

  • View all implemented features with descriptions
  • Check out planned features coming soon
  • See statistics about the application

Security & Privacy

  • 🔒 Your uploaded files are stored with unique session IDs
  • 🗑️ Files are automatically deleted when you:
    • Close the browser tab
    • After 2 hours of inactivity
  • 🛡️ Each session is isolated - no file conflicts between users

Configuration

You can customize these settings in Main.py:

  • Upload folder: uploads/ directory
  • Max file size: 50MB (MAX_CONTENT_LENGTH)
  • Session lifetime: 2 hours (PERMANENT_SESSION_LIFETIME)
  • Rows per page: 50 (in both Main.py and main.html)

Test Databases

The repository includes a script to generate sample databases for testing:

python create_test_databases.py

This creates 4 test databases in the test_databases/ folder:

  • customers.db - Simple customer data
  • ecommerce.db - Products, orders, and reviews
  • employees.db - Departments, employees, and projects
  • library.db - Books, members, and loans

Requirements

  • Python 3.7+
  • Flask 3.0.0
  • Werkzeug 3.0.1
  • pymysql 1.1.0 (MySQL support)
  • pymongo 4.6.0 (MongoDB support)
  • psycopg2-binary 2.9.9 (PostgreSQL support)
  • pyodbc 5.0.1 (SQL Server support)

Architecture

The application uses a modular architecture with:

  • Main.py - Flask web server and route handlers
  • database_handler.py - Database abstraction layer supporting multiple database types
  • templates/main.html - Responsive frontend with database type selection

Each database type has its own handler class implementing a common interface, making it easy to add new database types in the future.

Troubleshooting

MySQL Connection Issues

  • Check that MySQL server is running: sudo systemctl status mysql
  • Verify user has remote access permissions
  • Check firewall rules allow port 3306

PostgreSQL Connection Issues

  • Verify PostgreSQL is running: sudo systemctl status postgresql
  • Check pg_hba.conf for connection permissions
  • Ensure port 5432 is accessible

MongoDB Connection Issues

  • Verify MongoDB is running: sudo systemctl status mongod
  • Check authentication settings in MongoDB
  • For Atlas, ensure IP whitelist includes your address

SQL Server Connection Issues

  • Ensure ODBC Driver 17 is installed
  • Check SQL Server is configured for TCP/IP connections
  • Verify SQL Server authentication mode (Windows vs SQL Server auth)

License

MIT

About

Upload or connect to view your database in the web

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors