Тёмный

SQL Import Excel File to Table Using Python Pandas 

SyntaxByte
Подписаться 10 тыс.
Просмотров 40 тыс.
50% 1

Опубликовано:

 

25 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 31   
@syntaxbyte
@syntaxbyte 4 года назад
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.
@supragyasood9677
@supragyasood9677 2 года назад
What will be the syntax to insert data to SQL Server database
@K-Von
@K-Von 3 года назад
How could do it from multiple sheets to multiple sql tables?
@amintaleghani2110
@amintaleghani2110 3 года назад
thanks for your video. What will happen to the formulas that are the excel table after importing to SQL?
@brunosusak8358
@brunosusak8358 3 года назад
Is there a way to only append non-existing files, because otherwise I did if_exists='replace', so I don't get duplicated values
@YT95Ore0
@YT95Ore0 Год назад
Thank you! Super helpful.
@rexzw
@rexzw 3 года назад
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
@soumikbasu4880
@soumikbasu4880 3 года назад
one thing I dont have to create the table before hand right?
@narendrancr3745
@narendrancr3745 2 года назад
Hi, Thanks for this. How to see the table inserted using python
@sinofchaos10
@sinofchaos10 4 года назад
What should the line be if I'm trying to import the excel file into microsoft sql server?
@syntaxbyte
@syntaxbyte 4 года назад
SQLAlchemy supports various drivers to connect to MS SQL such as PyODBC which you can find details to on connection strings here: docs.sqlalchemy.org/en/13/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc Note that if you have a pre-configured ODBC source on the client you can use the shorter DSN syntax otherwise you need to use a longer hostname connection string.
@vaishakpillai6123
@vaishakpillai6123 2 года назад
Can anyone let me know how to stop appending data if the same data exists in the SQL table?
@jingyubu3176
@jingyubu3176 2 года назад
Thank you so much!!!!
@vijaysuman4137
@vijaysuman4137 3 года назад
its not working on more data means for 20 lakhs rows data insert
@SimonHerrgard
@SimonHerrgard 4 года назад
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.
@syntaxbyte
@syntaxbyte 4 года назад
What platform are you on? If Linux, did you install the python3-mysqldb package mentioned at the start of the video?
@SimonHerrgard
@SimonHerrgard 4 года назад
@@syntaxbytei´m doing the coding on an windows 10 machine. and have been using MySQl for another project recently.
@syntaxbyte
@syntaxbyte 4 года назад
It's not MySQL that's the issue, it's that python is missing the library it needs to connect to MySQL (MySQLdb). Try these instructions to get it installed: www.radishlogic.com/coding/python-3/installing-mysqldb-for-python-3-in-windows/ Note that I have not tested these instructions.
@yhaddad19
@yhaddad19 4 года назад
Amazing. Thanks!!!
@romiwahyudi5699
@romiwahyudi5699 7 месяцев назад
thanks a lot
@priyankakolli9075
@priyankakolli9075 2 года назад
if the excel is empty just with the header will it get imported to sql server?
@syntaxbyte
@syntaxbyte 2 года назад
What's the desired behaviour here? My recommendation would be to try because I don't think I've ever done that, it would probably create an empty table. But if you just want it to create a table, just create the table using SQL like you normally would. If you want it to do nothing, make sure you're on append mode and it shouldn't do anything.
@GaneshPatil-fs6cn
@GaneshPatil-fs6cn 4 года назад
How to specify data types and how to specify index from Python code only??
@syntaxbyte
@syntaxbyte 4 года назад
Please see the pinned comment for the data types. If you wish, specify index=True and the pandas indexes will be carried over to SQL. You can use regular methods to manipulate the pandas indexes, although that may require a look at pandas documentation and further familiarizing yourself with the library if you you are not already.
@GaneshPatil-fs6cn
@GaneshPatil-fs6cn 4 года назад
@@syntaxbyte Thank you soo much sir
@jakob2746
@jakob2746 Год назад
how to use for MSSQL and not MySQL?
@syntaxbyte
@syntaxbyte Год назад
See here: docs.sqlalchemy.org/en/20/core/engines.html#microsoft-sql-server
@chaityathota1334
@chaityathota1334 4 года назад
how to specify the data types please make a video on it
@syntaxbyte
@syntaxbyte 4 года назад
Please see pinned comment.
@michaelg9547
@michaelg9547 Год назад
would be nice if it actually worked
Далее
How to Use SQL with Excel using Python
16:52
Просмотров 122 тыс.
Физика пасты Карбонара 🧪🔬
00:57
Solving one of PostgreSQL's biggest weaknesses.
17:12
Просмотров 207 тыс.
Introducing Python in Excel
19:01
Просмотров 1,6 млн
Use Excel to Connect to SQL Server Data
13:51
Просмотров 112 тыс.
How to load data from excel to MySQL using Python
19:48