Skip to content

Latest commit

 

History

History
89 lines (68 loc) · 3.04 KB

README.md

File metadata and controls

89 lines (68 loc) · 3.04 KB

SQLite Database Merge Tool with Flask and Python

A Flask-based web application for merging SQLite databases. This tool helps you copy tables and data between production and development databases while preserving constraints and schema information.

Features

  • Database Comparison: View tables from source and destination databases side-by-side
  • Schema Inspection: View detailed table information including:
    • Column definitions (name, type, constraints)
    • Primary keys
    • Foreign keys
    • Indexes
    • Full CREATE TABLE schema
  • Structure Copying: Copy table structure (schema) from source to destination
  • Data Copying: Copy table data with two modes:
    • Replace: Delete existing data and insert new data
    • Append: Add data to existing records
  • Constraint Detection: Automatically identifies constraints that need to be copied
  • Data Preview: View first 100 rows of any table

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Create database directories (already created):
databases/
  source/      # Place source databases here
  destination/ # Place destination databases here

Usage

  1. Start the Flask application:
python app.py
  1. Open your browser to http://localhost:5000

  2. Place your SQLite databases in the appropriate directories:

    • Source databases → databases/source/
    • Destination databases → databases/destination/
  3. Use the web interface to:

    • Select source and destination databases
    • Choose tables to merge
    • View table information and constraints
    • Copy structure and/or data

Workflow

  1. Select Databases: Choose source and destination databases from dropdowns
  2. Choose Table: Select a table from the source database
  3. Review Info: Examine table structure, constraints, and row count
  4. Copy Structure: If the table doesn't exist in destination, copy the structure first
  5. Copy Data: Choose replace or append mode and copy the data

API Endpoints

  • GET /api/databases - List available databases
  • GET /api/tables/<db_type>/<db_name> - List tables in a database
  • GET /api/table-info/<db_type>/<db_name>/<table_name> - Get table schema and constraints
  • GET /api/table-data/<db_type>/<db_name>/<table_name> - Get table data (max 100 rows)
  • POST /api/copy-structure - Copy table structure
  • POST /api/copy-data - Copy table data

Safety Features

  • Confirmation prompts before destructive operations
  • Clear indication of replace vs. append modes
  • Constraint validation before data copying
  • Row count display to understand data volume

Tech Stack

  • Backend: Flask, Python, SQLite3
  • Frontend: Tailwind CSS, DaisyUI, Vanilla JavaScript
  • Database: SQLite

Notes

  • The tool works by reading databases from separate directories (not loading into memory)
  • Foreign key constraints are displayed but must be satisfied in the destination database
  • Indexes are created automatically when copying structure
  • Maximum 100 rows are displayed in data preview (all rows are copied during merge)