#!/bin/bash

function scriptDir {
  source="${BASH_SOURCE[0]}";
  while [ -h "$source" ];
  do
    dir="$( cd -P "$( dirname "$source" )" && pwd )";
    source="$(readlink "$source")";
    [[ $source != /* ]] && source="$dir/$source"; # if $source was a relative symlink, we need to resolve it relative to the path where the symlink file was located
  done;
  
  echo "$( cd -P "$( dirname "$source" )" && pwd )";
}

location=$(scriptDir);

echo "START TRANSACTION;";

for dictionary in "$location"/dictionary/*.tsv;
do
  "$location/dictionary/to_sql.sh" "$dictionary";
done;

echo "COMMIT;";