Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

To start off, this is not about loading data from within mysql itself, but using the command-line tool "mysqlimport".

I am using it to load a CSV directly into a table and need to see the warnings it has generated. I cannot seem to get warnings to display with verbose nor debugging turned on. Any ideas?

(mysql 5.0.5)

share|improve this question

3 Answers 3

up vote 13 down vote accepted

Yeah, this was a nuisance I had to deal with a while ago. Here's a snippet from a script that dealt with converting a bunch of CSV files into mysql tables:

COLLIST=`head -1 $table.csv`
mysql --execute="LOAD DATA INFILE '$WORKDIR/$table.csv' INTO TABLE $table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"' IGNORE 1 LINES ($COLLIST); SHOW WARNINGS" > $table.output

The magic is (as Eduard previously mentioned) is to execute the LOAD DATA INFILE and the SHOW WARNINGS commands together in the same session, as mysqlimport doesn't provide a way to get at the warnings directly.

share|improve this answer
    
Sweet, thank you! I had just begun writing a statement like this after seeing Eduard's comment. Thanks yo! Thanks –  brink Dec 21 '09 at 19:50

Like the others said the real problem is that for SHOW WARNINGS to work you have to be in the same connected session. mysqlimport disconnects from the session as soon as it's finished importing, making the capture of it's warnings impossible in it's current version. Sounds like an opportunity to donate a patch. :)

share|improve this answer

I've found no way to print warnings with mysqlimport either. But since mysqlimport does nothing but "LOAD DATA INFILE" why don't you use the mysql command to import the data followed by a "SHOW WARNINGS"?

share|improve this answer
    
Thanks! Kind of irritating mysqlimport doesn't really play nice :/ –  brink Dec 21 '09 at 19:51
    
Use the "SHOW WARNINGS;" command after "LOAD". –  Eduard Wirch Dec 27 '09 at 15:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.