Converting CSV to SQL with Python

preview_player
Показать описание
A simple example of how to use Python to read a simple CSV file and make an SQL database.
Рекомендации по теме
Комментарии
Автор

Thank you! I followed along exactly as you demonstrated and I got my CSV into sqlite programmatically! Thank you!

pleabargain
Автор

Thank you so much!

This was exactly what I have needed for the last five hours!

You are a god send!

dominickbudzisz
Автор

Thanks for the clear explanation and clean/clear code! It's much appreciated. There very well could be some user-error on my part, but I found that executing and committing one row at a time was very slow for me (again, maybe this was my fault!). In a similar approach, I dumped the csv file contents into a list (using a list comprehension) and then used "cur.executemany()" to populate the database all at once...this worked for me and my data (about 30 MB) in probably one second or less. Just wanted to share in case others experience a similar issue.

Another alternative is to read the csv file into a Pandas dataframe and then output the dataframe to a sqlite database.

danielevans
Автор

Thank you ..it was a wonderful explaination...for csv file

labheshlalka
Автор

Please, how do you manage to print the row into a text file. how did you manage to save your print(row) to a text file. thank you.

anthonywilly
Автор

How can we initialise a column if it has date time values
Like this:
datetime=DATETIME(row[0])
??

mustafadar
Автор

Thank you so much... This helped me a lot

jananishanmugam
Автор

Hi

I need to compare data text file with db table below scenarios

Note: text file don't have header

1. Count of records file and table
2. Is file data same as in table

It would be great if u share any video or link

Sreenu
Автор

i'm trying to do an webapp to query some data an this is exactly what i need, thank you so much!!

creyssu
Автор

My acutally Problem on this code is: attribute4 = row[4]
IndexError: list index out of range. The last row is really speciality, thats why some data sets have 4 entries and some 5, but I don't know how i could say: if the last row don't exist in some datasets that you can add an entry for attribute4 = "N/A". I'm to new in python xD.

mainfurina
Автор

Thanks for the tutorial! Your exact code didn't work for me ... I had to change all the '?' to '%s' for my code to work, but that was about it!

hjsjsetyjdytj
Автор

I'm enticed to switch over for scripting race conditions in nodejs are killing me.

nazarm
Автор

Whatever I do I keep getting an error like ' TypeError: function takes at most 2 arguments (10 given) '.
Can anyone give me hint on how to solve that, please?

martygeorgiev
Автор

no way i am a big fan of EXO, the korean boy band and i am learning python... seeing exoplanet here is just an amazing coincidence

goodnight
Автор

SQLite studio is do it for you without any code dude....

adamnagy
Автор

This is a great example how not to do this task.
This is sadly what I see when working with so called web programmers that are touting a great effort in their attempt to not use the most useful and in some cases expensive piece of their system -their database.

Please viewers, use this as an sql example in python.

Never import DSV in a db especially in volume by sql statement per row. This is slow, loads your db cpu and is just to efficient.

I’m so sad when I see web systems just crippled by this type of using the db.

OggVorbis
join shbcf.ru