Ι am trying to import a csv file into an existing
mysql 5.7
table.
Here is the command (the db is in docker with bind mount for persistence)
mysql -h 127.0.0.1 -uroot -prootpass --local_infile=1 jira_statistics -e "LOAD DATA LOCAL INFILE '/home/centos/bugs.csv' INTO TABLE bugs FIELDS TERMINATED BY ','"
However:
mysql> select * from bugs;
Empty set (0.05 sec)
The file cannot be loaded because there is a foreign key constraint. I need to be able to catch errors like this (and any others that might occur) as an exit code since I will be scripting a large number of imports like this.
There is no error returned to the command line, and the docker
logs of the MySQL container show no errors.
What is more, the exit code of the mysql
command is 0
!
Any ideas?
Asked by pkaramol
(213 rep)
Feb 14, 2019, 02:12 PM
Last activity: Feb 18, 2025, 09:01 PM
Last activity: Feb 18, 2025, 09:01 PM