executing mysql load statement from shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting executing mysql load statement from shell script
# 1  
Old 01-22-2009
Java executing mysql load statement from shell script

Hi,

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!

With Regards
Dileep Pattayath
# 2  
Old 01-22-2009
When using that in a shell script like for example:
Code:
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.
# 3  
Old 01-22-2009
MySQL

Thats perfect! Thanks a lot mate.

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?

With Regards
Dileep Pattayath
# 4  
Old 01-22-2009
# 5  
Old 01-22-2009
MySQL

I did it, haven't found anything.
Anyway let's keep on trying.if you got any idea or info about this,please update this thread

Thanks mate, you provided very useful information.

With Regards
Dileep Pattayath
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to keep staying on remote server after executing a shell script with if then exit end statement?

i have a "if .. then exit end " in s shell script on remote servers. now the connection to the remote server got killed after i run this script on the remote servers. How do i run this script on remote hosts and still keep remote connections alive after executing the script. Thank you. (10 Replies)
Discussion started by: moonmonk
10 Replies

2. Shell Programming and Scripting

Balance the load of files across queues using shell script

Hi, I need to balance the load to be processed by the system using shell script. The scenario is like below: Suppose there are some files in a directory: -rw-rw-r-- 1 usr usrgrp 456432306 Oct 23 07:53 abc_queue_q1 -rw-rw-r-- 1 usr usrgrp 4123934 Oct 23 07:53... (1 Reply)
Discussion started by: vsachan
1 Replies

3. Shell Programming and Scripting

ERROR in executing mysql querys in shell scripting

Hi All, Please see the below script for mysql 3 commands. Its giving me the right output for all three commands but showing some errors in first two commands , i guess there might be an issue with date. Can anyone help me . #! /bin/bash TABLE_NAME=testingddatabase USER_NAME=root... (3 Replies)
Discussion started by: aish11
3 Replies

4. Programming

Sybase load statement issue

hi, I am trying to load a sybase table using a file ( unit separator is the delimiter) which is in IQ server. I Used load statment as below execute ('LOAD TABLE schemaname.tablename (' || ' name, age, date, Symbols) from ' || ' '' /filepath/file.txt '' ' || ' QUOTES off ' || ' DELIMITED... (0 Replies)
Discussion started by: irudayaraj
0 Replies

5. Homework & Coursework Questions

Problem with executing a possible if or case statement script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Create a phonebook program. It should use functions to perform the required tasks. It should be menu-based,... (1 Reply)
Discussion started by: Rgasin02
1 Replies

6. Shell Programming and Scripting

shell script to create disk load

friends , need a shell script to create a disk load. can any one pls guide me with how this can be implemented. Pls provide the concept. from there i will try to design my script. (3 Replies)
Discussion started by: achak01
3 Replies

7. Shell Programming and Scripting

sh and MySQL LOAD DATA

I have a csv file in a folder that is roughly 500,000 rows long. Rather than using PHP, I would like to use SH to run a MYSQL LOAD DATA command to load the data in, as I think it would be much faster and would not cause any memory problems associated with PHP. But the problem is, I am not... (18 Replies)
Discussion started by: worchyld
18 Replies

8. Shell Programming and Scripting

Executing a Oracle SQL statement in a UNIX script

Hi All, I need to select one column from a table based upon the passed in parameter. I tried this: sqlplus -silent $MISP_USER << EOF set feedback off; set verify off; set sqlprompt "" SELECT mail_flag FROM dailyjobs WHERE job_name = '$1'; exit 0 EOF exit... (1 Reply)
Discussion started by: ganga.dharan
1 Replies

9. Shell Programming and Scripting

Need help in wrting Load Script for a Load-Resume type of load.

hi all need your help. I am wrting a script that will load data into the table. then on another load will append the data into the existing table. Regards Ankit (1 Reply)
Discussion started by: ankitgupta
1 Replies

10. Shell Programming and Scripting

How to write DB2 Load Utility in Shell script

Hi, I am a beginner. I need an example of using DB2 Load Utility in Shell script. I appreciate if anyone could help me about it. Thanks, Paris (0 Replies)
Discussion started by: parisbeginner
0 Replies
Login or Register to Ask a Question