Skip to content

Repository files navigation

๐Ÿ“Š Excel-Driven ETL Tool

Python Pandas SQLAlchemy License

A powerful, configuration-driven ETL tool that uses Excel spreadsheets to define data migration rules between databases.

๐Ÿš€ Overview

This Excel-Driven ETL Tool simplifies database migration and data transformation processes by using an Excel file as a configuration template. Instead of hard-coding migration logic, users can define source tables, destination schemas, column mappings, and transformation rules directly in an intuitive Excel interface.

โœจ Key Features

  • ๐Ÿ“‹ Excel Configuration: Define ETL processes using familiar Excel spreadsheets
  • ๐Ÿ”— Multi-Database Support: Works with PostgreSQL, MySQL, and other SQL databases via SQLAlchemy
  • ๐Ÿ›ก๏ธ Secure Connection Management: Database credentials stored in hidden JSON files
  • โœ… Column Validation: Automatic validation of source columns against database schemas
  • ๐Ÿ“ Comprehensive Logging: Detailed execution logs for monitoring and debugging
  • โฑ๏ธ ETL Timestamp Tracking: Automatic addition of processing timestamps to migrated data
  • ๐ŸŽฏ Flexible Table Selection: Process specific tables or entire database schemas

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 โ”‚    โ”‚                  โ”‚    โ”‚                 โ”‚
โ”‚  etl_driver.xlsxโ”‚โ”€โ”€โ”€โ–ถโ”‚ excel_driven_etl โ”‚โ”€โ”€โ”€โ–ถโ”‚ Destination DB  โ”‚
โ”‚  Configuration  โ”‚    โ”‚     Python       โ”‚    โ”‚                 โ”‚
โ”‚                 โ”‚    โ”‚     Script       โ”‚    โ”‚                 โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ–ฒ                        โ”‚                        โ–ฒ
         โ”‚                        โ–ผ                        โ”‚
         โ”‚              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”               โ”‚
         โ”‚              โ”‚   secrets.json   โ”‚               โ”‚
         โ”‚              โ”‚   Credentials    โ”‚               โ”‚
         โ”‚              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜               โ”‚
         โ”‚                                                 โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        Source Database

๐Ÿ“ฆ Installation

Prerequisites

  • Python 3.7 or higher
  • pip package manager
  • Access to source and destination databases

Dependencies

pip install pandas sqlalchemy psycopg2-binary openpyxl requests

Quick Setup

  1. Clone or download the project files:

    git clone <your-repo-url>
    cd excel-driven-etl
  2. Install dependencies (Not there yet):

    pip install -r requirements.txt
  3. Configure your databases (see Configuration section below)

โš™๏ธ Configuration

1. Database Credentials (secrets.json)

Create a secrets.json file with your database connection details:

{
  "database_connections": {
    "source_db": {
      "host": "localhost",
      "database": "source_database",
      "username": "your_username",
      "password": "your_password",
      "db_type": "postgresql",
      "port": 5432
    },
    "dest_db": {
      "host": "localhost",
      "database": "destination_database",
      "username": "your_username",
      "password": "your_password",
      "db_type": "postgresql",
      "port": 5432
    }
  }
}

2. ETL Configuration (etl_driver.xlsx)

The Excel driver file contains multiple sheets:

Config Sheet

Setting Value Description
source_db_key source_db Reference to connection in secrets.json
source_schema public Source database schema
dest_db_key dest_db Reference to destination connection
dest_schema etl_schema Destination database schema

Table Configuration Sheets

Each additional sheet represents a table to migrate. Sheet names should match source table names.

Example sheet "users":

Column_Name New_Name Filter
user_id id
first_name fname
last_name lname
email email_address
created_date

๐Ÿš€ Usage

Basic Execution

python excel_driven_etl.py

Command Line Options

The script (eventually will) accept command-line arguments and generates detailed logs:

# Run with specific configuration
python excel_driven_etl.py

# Check logs
tail -f excel_driven_etl.log

Execution Flow

  1. ๐Ÿ”ง Initialization: Load configuration and establish database connections
  2. ๐Ÿ“Š Validation: Verify column existence in source tables
  3. ๐Ÿ”„ Processing: Extract data from source, transform as needed
  4. ๐Ÿ’พ Loading: Insert transformed data into destination tables
  5. ๐Ÿ“ Logging: Generate comprehensive execution reports

๐Ÿ“‹ Features in Detail

Column Validation

  • Automatically validates Excel-defined columns against actual database schemas
  • Provides detailed logging of matched and unmatched columns
  • Continues processing with valid columns only

Data Transformation

  • Adds ETL_DATE_TIME_ZONE timestamp to all migrated records
  • Supports column renaming (planned feature)
  • Filtering capabilities (planned feature)

Error Handling

  • Comprehensive exception handling and logging
  • Graceful handling of missing columns or tables
  • Connection management and cleanup

๐Ÿ“ File Structure

excel-driven-etl/
โ”œโ”€โ”€ excel_driven_etl.py      # Main ETL script
โ”œโ”€โ”€ etl_driver.xlsx          # Excel configuration file
โ”œโ”€โ”€ secrets.json             # Database credentials (create this)
โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ README.md                # This file
โ””โ”€โ”€ excel_driven_etl.log     # Execution logs

๐Ÿ”ฎ Planned Enhancements

  • Better error handling: There are some additional areas where we vould do error checks and maybe gracefully exit when encountering errors
  • Column Renaming: Use New_Name column for destination column names
  • Data Filtering: Implement row-level filtering using Filter column
  • Table Prefixes/Suffixes: Add configurable table name modifications
  • Progress Tracking: Enhanced progress indicators and validation
  • Database Permissions: Improved permission handling for destination schemas
  • Incremental Loading: Support for delta/incremental data loads
  • Data Type Mapping: Automatic data type conversion between databases
  • Parameterize the driver file: Add a parameter for the excel file path. Consider changing the log file name to include the excel file name

๐Ÿ› Troubleshooting

Common Issues

Connection Errors

  • Verify database credentials in secrets.json
  • Check network connectivity to database servers
  • Ensure proper database permissions

Column Mismatch Errors

  • Review Excel column names against actual table schemas
  • Check logs for specific unmatched columns
  • Verify table names match sheet names exactly

Permission Errors

  • Ensure destination database user has CREATE TABLE permissions
  • Verify schema exists or user can create schemas

๐Ÿ“Š Monitoring and Logs

The tool generates comprehensive logs including:

  • Execution start/end times
  • Connection establishment status
  • Column validation results
  • Data processing progress
  • Error details and stack traces
  • Performance metrics

Log file location: excel_driven_etl.log

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author

Joseph P. Merten

๐Ÿ™ Acknowledgments


Made with โค๏ธ for data engineers who love Excel configurations!

About

This is an excel driven etl script.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages