forked from IT2002/AppStore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_sql.sh
More file actions
executable file
·35 lines (32 loc) · 894 Bytes
/
Copy pathadd_sql.sh
File metadata and controls
executable file
·35 lines (32 loc) · 894 Bytes
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
# Construct the URI from the .env
DB_HOST=''
DB_NAME=''
DB_USER=''
DB_PORT=''
DB_PASSWORD=''
while IFS= read -r line
do
if [[ $line == DB_HOST* ]]
then
DB_HOST=$(cut -d "=" -f2- <<< $line | tr -d \')
elif [[ $line == DB_NAME* ]]
then
DB_NAME=$(cut -d "=" -f2- <<< $line | tr -d \' )
elif [[ $line == DB_USER* ]]
then
DB_USER=$(cut -d "=" -f2- <<< $line | tr -d \' )
elif [[ $line == DB_PORT* ]]
then
DB_PORT=$(cut -d "=" -f2- <<< $line | tr -d \')
elif [[ $line == DB_PASSWORD* ]]
then
DB_PASSWORD=$(cut -d "=" -f2- <<< $line | tr -d \')
fi
done < ".env"
URI="postgres://$DB_USER:$DB_PASSWORD@$DB_HOST:$DB_PORT/$DB_NAME"
# Run the scripts to insert data.
psql ${URI} -f sql/AppStoreClean.sql
psql ${URI} -f sql/AppStoreSchema.sql
psql ${URI} -f sql/AppStoreCustomers.sql
psql ${URI} -f sql/AppStoreGames.sql
psql ${URI} -f sql/AppStoreDownloads.sql