Search code examples
pythonmysqlcsvmysql-connector-python

Insert data into mysql from sql file or using csv file


I have an db.sql file and I tried inserting the data from it to my local MYSQL using the command: mysql -u root -p chitfund < db.sql . It doesn't show any error and also doesn't print anything. But when I try to see the tables in my db, it shows now tables. I have the data in the form of .csv also. I tried inserting using mysql.connector , but it is not installing and throws an error. Is there any other way to insert the data using the sql or csv files.


Solution

  • The problem was with my .sql file. It didn't have any insert or create statements. I assumed it has the statements and the data is not being inserted. After having all the insert statements for inserting the data, it worked properly