Code Monkey home page Code Monkey logo

excel_to_mysql_importer's Introduction

Excel_to_MySQL_Importer

This project provides a Python script to read data from an Excel file and insert it into specified MySQL database tables. The script uses pandas for reading Excel files and pymysql for interacting with the MySQL database. This is useful for data migration tasks or batch data insertion from Excel files to MySQL databases.

Features

  • Reads data from specified sheets in an Excel file using pandas.
  • Connects to a MySQL database using pymysql.
  • Inserts the data into corresponding MySQL tables.
  • Supports bulk insertion for efficiency.

How to Use

  1. Install Required Libraries: Ensure you have pymysql and pandas installed.

    pip install pymysql pandas
  2. Configure Database Connection: Update the connection parameters (host, user, password, db) in the execute_sql function.

  3. Map Excel Sheets to MySQL Tables: Update the table_name_dict dictionary in the main function to map Excel sheet names to MySQL table names.

  4. Specify the Path to Your Excel File: Update the File_Path variable in the main function to point to your Excel file location.

    File_Path = "C:\\Path\\To\\Your\\data.xlsx"
  5. Run the Script: Execute the script to read data from the Excel file and insert it into the MySQL tables.

    python Excel_to_MySQL_Importer.py

Example

In this script, the Excel file data.xlsx located on the desktop is read. The data from the sheets SPC and sales are inserted into the MySQL tables Schema1.settings_spc and Schema2.sales, respectively.

Related Repositories

Prerequisites

  • Python 3.x
  • MySQL server
  • Necessary Python libraries: pymysql, pandas

Notes

  • Ensure your MySQL server is running and accessible.
  • Update the SQL insert command if the Excel column names differ from the MySQL table column names.

excel_to_mysql_importer's People

Contributors

bangkokpicasso avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.