-
Notifications
You must be signed in to change notification settings - Fork 2
/
feedback.sh
executable file
·49 lines (42 loc) · 1.14 KB
/
feedback.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh
# Export data from MySQL database back to ipcc-facts-checking
# to perform comparisons for Quality Assurance
#
# USAGE:
# feedback.sh [user] [host] [password]
# with
# user - optional, string, database user name, defaults to 'root'
# host - optional, string, database host name, defaults to 'localhost'
# password - optional, string, database user password,
# defaults to 'no password' which provides no password;
# an empty string results in a prompt for password.
user=${1:-'root'}
host=${2:-'localhost'}
password=${3:-'no password'}
if [ "$password" = 'no password' ]
then
passwordParam=''
else
passwordParam="--password $password"
fi
database=ipcc
query="mysql --host $host --user $user $passwordParam"
# change to the script's directory
cd $(dirname $0)
# change to feedback directory
cd feedback
feedback()
{
dataset=$(dirname $1)
echo "Export ipcc-fact-checking/$dataset/back.csv"
$query $database < $1 \
| awk -f ../tsv2csv.awk > "../ipcc-fact-checking/$dataset/back.csv"
}
for script in */*/*/back.sql
do
feedback "$script"
done
# clean-up
$query $database << EOF
DROP VIEW feedback_chapter;
EOF