Skip to content

Python script reads SQL queries from an Excel sheet, executes them on a MySQL database, and updates the data.

License

Notifications You must be signed in to change notification settings

theshubhamgour/py-mysql-excel-conectado

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py-mysql-excel-conectado

Python script reads SQL queries from an Excel sheet, executes them on a MySQL database, and updates the data.

Description

This Python project takes an Excel sheet containing SQL queries as input and executes them using the MySQL Connector library to fetch data from a MySQL database. The project connects to a database with two tables, "table1" and "table2", and then inserts five rows of data into them. The "table2" table is connected to "table1" with a foreign key constraint.

The project uses the openpyxl library to read the Excel sheet and extract the SQL queries. It then uses the mysql.connector library to connect to the MySQL database, execute the queries, and fetch the data. After executing each query, it commits the changes to the database and then closes the cursor. Finally, it closes the database connection.

This project is particularly useful for automating repetitive database tasks, such as inserting data into tables from an Excel sheet, without the need for manual input.

After Release v2

We Created a Database named my_database in which we created tables for demonstrating the project

image

There are three tables namely - table1 table2 and users

image

Below we have created the sample tables for demostration purpose

image

This is the sheet where the SQL queries are entered as input.

image

This is the output after running the program

image

About

Python script reads SQL queries from an Excel sheet, executes them on a MySQL database, and updates the data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages