Import partial data into MySQL from CSV

I have a CSV, which is a partial projection of the origin table. I have the same table structure in my database.

I would like to import only those columns into my database, given that there are no additional NOT NULL restrictions (I explicitly disabled some of them). I do not know how to import them.

I tried the following: from MySQL Workbench, right-click on the table and then Edit table data , then on the screen I tried the button "Import records from an external file", downloaded the CSV file, but got the following error

 [Window Title] MySQL Workbench [Main Instruction] Error importing recordset [Content] error calling Python module function SQLIDEUtils.importRecordsetDataFromFile [OK] 

Column names are the same as in the database, but they are partial (not all columns are like a database). The table is currently empty.

What can I do to import data into MySQL?

+6
source share
3 answers

It turns out that this is a mistake that the tool gives for ANY problems with importing CSV data. They opened the error for more descriptive error answers.

It turned out to me that it cannot work with line breaks without Windows. So if your file comes from Unix / Linux or Mac, this will not work. You can simply open it in Excel, although you can save it as MS-DOS CSV again, and then it works. Other things that can make him get out are the use of ";".

In addition, the tool has no column display options, so you need your import file to match the table setting. If you have invalid column matches or incorrect data matches, they will also cause.

+7
source

I got the same question and error when I imported the csv file to MAC Mysqlworkbench.

I restored my file as comma-separated windows ( .csv ). This works for me.

+1
source
  • Check if you have import permissions (when pasting), and if you import cleanup checking old data, you have permission to delete.
  • If this does not help, create a new table with minimal restrictions that has exactly the same columns as in the CSV file, try importing it. If everything is fine - just update / paste into your target table.
  • If this does not help, try importing to another database.
  • If this does not help, check the CSV file - is everything okay? (maybe he should try first)
0
source

Source: https://habr.com/ru/post/952349/


All Articles