I have a piece of shell script which will connect to mysql database and execute a load statement\(which will load datas in a file to the database table\).The code is working and the data is in the tables.
Now my requirement is, i need to grab the output from the load statement execution whether it will be a success message or failure.If in case the load statement fail i will get the below information while executing from cmd line.
mysql> load data local infile test.txt' into table userdata;
Query OK, 0 rows affected, 14800 warnings (0.05 sec)
Records: 3762 Deleted: 0 Skipped: 3762 Warnings: 14800
I need the same info when am doing this operation from a shell script.
Your help is appreciated!
When using that in a shell script like for example:
mysql -uroot -psomepass mydb < dothat.sql
... you can always check with the shell variable $? what happened; just echo it. 0 is success, 1 is a fail. If you need more verbose output, man mysql says add a -v or -vv or -vvv. -vvv should be as detailed as if doing that interactive on the mysql prompt.
Do you know how we can see the skipped records from a load statement. Like in Oracle we can specify a dsc file or bad file from which we can track the rejected or discarded records, like that anything in mysql?