MySQL Forums
Forum List  »  General

Re: Unable to import CSV file
Posted by: Mikey Terracano
Date: April 29, 2015 12:18PM

It has obviously something to do with the way Wamp processes my CSV file.

Irrespective if the fields in the line of the CSV file are enclosed in double quotes or not - i.e. if they're numbers or strings - WAMP generates an INSERT statement which has all fields enclosed in simple quotes:

INSERT INTO `test_a` VALUES ('1', '42', '"PINCABES01"', '1', '"Aba"')

And the it adds:

MySQL said:
#1452 - Cannot add or update a child row: a foreign key constraint fails (`floraro`.`test_a`, CONSTRAINT `test_a_ibfk_1` FOREIGN KEY (`taxonref_RO_fk`) REFERENCES `taxonref` (`taxonref_id`))

This is false. If I eliminate the simple quotes and copy this command "by hand", as an SQL statement, it works perfectly.

It also works without the double quotes, keeping only the simple ones, including for values that are numbers (numeric).

I think that the WAMP section for importing CSV files may have a problem.

Options: ReplyQuote


Subject
Written By
Posted
Re: Unable to import CSV file
April 29, 2015 12:18PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.