简体   繁体   中英

Insert Information to MySQL from multiple related excel files

So i have this huge DB schema from a vehicle board cards, this data is actually stored in multiple excel files, my job was to create a database scheema to dump all this data into a MySql, but now i need to create the process to insert data into the DB.

This is an example of how is the excel tables sorted: Excel 数据示例

The thing is that all this excel files are not well tagged. My question is, what do i need to do in order to create a script to dump all this data from the excel to the DB? I'm also using ids, Foreign keys, Primary Keys, joins, etc.

在此处输入图片说明

I've thought about this so far:

1.-Normalize the structure of the tables in Excel in a good way so that data can be inserted with SQL language.

2.-Create a script in python to insert the data of each table.

Can you help out where should i start and how? what topics i should google?

With pandas you can easily read from excel (both csv and xlsx) and dump the data into any database

import pandas as pd
df = pd.read_excel('file.xlsx')
df.to_sql(sql_table)

If you have performance issues dumping to MySQL, you can find another way of doing the dump here python pandas to_sql with sqlalchemy : how to speed up exporting to MS SQL?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM