SQL Import Excel File to Table Using Python Pandas

preview_player
Показать описание
Use python pandas to insert data into an SQL table from an Excel file. This method takes advantage of pandas' read_excel and to_sql functions to cleanly import data from an Excel file into any SQL database.

Works officially with the following SQL database providers: PostgreSQL, MySQL, Oracle, Microsoft SQL Server and SQLite.

Music: X Ray Vision by Slynk from YouTube audio library
Рекомендации по теме
Комментарии
Автор

How to specify data types: add "from sqlalchemy.types import String, SmallInteger" replacing String and SmallInteger with the types you need.

Then, do "df.to_sql('people', con=engine, if_exists='replace', index=False, dtype={'First Name': String(length=255),
'Last Name': String(length=255),
'Age': SmallInteger, 'Phone Number': String(length=255)})"

Sorry for not including this in the video, I didn't think it would be a super common need.

syntaxbyte
Автор

What will be the syntax to insert data to SQL Server database

supragyasood
Автор

How could do it from multiple sheets to multiple sql tables?

K-Von
Автор

please help, my database is linked with PKs and FKs, I modified the table with a new attribute, how can I append the new data from a excel file to that specific column

rexzw
Автор

one thing I dont have to create the table before hand right?

soumikbasu
Автор

Is there a way to only append non-existing files, because otherwise I did if_exists='replace', so I don't get duplicated values

brunosusak
Автор

thanks for your video. What will happen to the formulas that are the excel table after importing to SQL?

amintaleghani
Автор

its not working on more data means for 20 lakhs rows data insert

TECH_WITH_VKS_ZERO_TO_HERO
Автор

Can anyone let me know how to stop appending data if the same data exists in the SQL table?

vaishakpillai
Автор

Hi, Thanks for this. How to see the table inserted using python

narendrancr
Автор

if the excel is empty just with the header will it get imported to sql server?

priyankakolli
Автор

When trying this i unfortunate keep getting an error saying "ModuleNotFoundError: No module named 'MySQLdb'
", do you have any ideas on why and even maybe a solution.

SimonHerrgard
Автор

What should the line be if I'm trying to import the excel file into microsoft sql server?

sinofchaos
Автор

How to specify data types and how to specify index from Python code only??

GaneshPatil-fscn
Автор

how to specify the data types please make a video on it

chaityathota
join shbcf.ru