Wednesday, 21 August 2013

pass parameter from bash to mysql script

pass parameter from bash to mysql script

I'm trying to pass parameter from bash script to mysql script. The bash
script is
#!/bin/bash
for file in `ls *.symbol`
do
path=/home/qz/$file
script='/home/qz/sqls/load_eval.sql'
mysql -u qz -h compute-0-10 -pabc -e "set @pred = '$path'; source $script;"
done
The load_eval.sql is
use biogrid;
load data local infile @pred into table lasp
fields terminated by ','
lines terminated by '\n'
(score, symbols);
When running the bash script, I got error the message:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '@pred
into table lasp ..
It seems the value of the parameter @pred is not passed into mysql script.

No comments:

Post a Comment