Skip to content

Commit

Permalink
merged
Browse files Browse the repository at this point in the history
  • Loading branch information
lwheng committed Jun 14, 2013
2 parents 9f875bc + 4baecdd commit c6d3b83
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion generate_sql_for_transfer_to_db.sh
Expand Up @@ -5,6 +5,7 @@ function help() {
" $0 <File_1> <File_2>\n\n" \
" <File_1> : The file with key:value pairs to be added to database\n" \
" <File_2> : The file to be compared against\n\n" \
" <Market ID> : The market ID\n\n" \
"Output:\n" \
" An SQL file that contains INSERT statements for (File_1.keys - File_2.keys)" >&2;

Expand All @@ -20,6 +21,11 @@ if [[ -z "$2" ]]; then
exit 1;
fi

if [[ -z "$3" ]]; then
help
exit 1;
fi

# Assign to variables
FILE1=$1
FILE2=$2
Expand Down Expand Up @@ -59,6 +65,7 @@ rm FILE1_KEYS FILE1_FORMATTED FILE2_KEYS FILE2_FORMATTED
# printf "%b" "${LINE:$INDEX}"
# echo -ne "',1,'${MARKETID}',1)\n"
# done < TO_BE_INSERTED

cat TO_BE_INSERTED | sort | sed "s/'/''/g" | sed "s/\([a-z|\.|0-9|_|A-Z]*\)=\(.*\)/INSERT APPCONFIG \(key_name, key_value, critical_value, marketid, modified_by\) VALUES \('\1', '\2', 1, '${MARKETID}', 1)/"

cp $FILE1 TEST
Expand All @@ -73,4 +80,4 @@ for SEARCH in $(cat KEYS_TO_BE_DELETED)
rm TO_BE_INSERTED
rm KEYS_TO_BE_DELETED
cp $FILE1 $FILE1.bak.properties
mv TEST $FILE1
mv TEST $FILE1

0 comments on commit c6d3b83

Please sign in to comment.