This repository has been archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathsql_data_init.sh
executable file
·80 lines (63 loc) · 2.59 KB
/
sql_data_init.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# set -euo pipefail
IFS=$'\n\t'
usage() { echo "Usage: sql_data_init.sh -s <SQL Server FQDN> -u <sql username> -p <sql password> -d <databaseName> " 1>&2; exit 1; }
declare sqlServerFQDN=""
declare sqlServerUsername=""
declare sqlPassword=""
declare sqlDBName=""
# Initialize parameters specified from command line
while getopts ":s:u:p:d:" arg; do
case "${arg}" in
s)
sqlServerFQDN=${OPTARG}
;;
u)
sqlServerUsername=${OPTARG}
;;
p)
sqlPassword=${OPTARG}
;;
d)
sqlDBName=${OPTARG}
;;
esac
done
shift $((OPTIND-1))
if [[ -z "$sqlServerFQDN" ]]; then
echo "Enter FQDN to SQL Server:"
read sqlServerFQDN
[[ "${sqlServerFQDN:?}" ]]
fi
if [[ -z "$sqlServerUsername" ]]; then
echo "Enter the SQL Server User name:"
read sqlServerUsername
[[ "${sqlServerUsername:?}" ]]
fi
if [[ -z "$sqlPassword" ]]; then
echo "Enter the sql server password:"
read sqlPassword
[[ "${sqlPassword:?}" ]]
fi
if [[ -z "$sqlDBName" ]]; then
echo "Enter the name of the SQL Server DB that was provisioned in shared infrastructure:"
read sqlDBName
fi
echo "Importing Devices"
bcp Devices in ./data_load/Devices_export.txt -S $sqlServerFQDN -U $sqlServerUsername -P $sqlPassword -d $sqlDBName -c -t ','
echo "Importing factMLOutputData"
bcp factMLOutputData in ./data_load/factMLOutputData_export.txt -S $sqlServerFQDN -U $sqlServerUsername -P $sqlPassword -d $sqlDBName -c -t ','
echo "Importing IOTHubDatas"
bcp IOTHubDatas in ./data_load/IOTHubDatas_export.txt -S $sqlServerFQDN -U $sqlServerUsername -P $sqlPassword -d $sqlDBName -c -t ','
echo "Importing POIs"
bcp POIs in ./data_load/POIs_export.txt -S $sqlServerFQDN -U $sqlServerUsername -P $sqlPassword -d $sqlDBName -c -t ','
echo "Importing TripPoints"
bcp TripPoints in ./data_load/TripPoints_export.txt -S $sqlServerFQDN -U $sqlServerUsername -P $sqlPassword -d $sqlDBName -c -t ','
echo "Importing Trips"
bcp Trips in ./data_load/Trips_export.txt -S $sqlServerFQDN -U $sqlServerUsername -P $sqlPassword -d $sqlDBName -c -t ','
echo "Importing UserProfiles"
bcp UserProfiles in ./data_load/UserProfiles_export.txt -S $sqlServerFQDN -U $sqlServerUsername -P $sqlPassword -d $sqlDBName -c -t ','
echo "Importing POISource"
bcp POISource in ./data_load/POISource_export.txt -S $sqlServerFQDN -U $sqlServerUsername -P $sqlPassword -d $sqlDBName -c -t ','
echo "Importing TripPointSource"
bcp TripPointSource in ./data_load/TripPointSource_export.txt -S $sqlServerFQDN -U $sqlServerUsername -P $sqlPassword -d $sqlDBName -c -t ','