Skip to content

Commit bcaaeda

Browse files
authored
Dev
2 parents 18585e7 + 3b1cf62 commit bcaaeda

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

.github/workflows/functional_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
fi
8282
8383
- name: Reset database
84-
run: docker compose run scraper python3 src/db.py create_tables
84+
run: docker compose run scraper sh -c 'apk add postgresql-client && ./reset_db.bash;'
8585

8686
- name: Run scraper again (to test cache)
8787
run: docker compose run scraper python3 src/main.py --db --all-colleges --ratings

docker-compose.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ services:
33
scraper:
44
build: .
55
environment:
6+
SCHEDULER_DB_USERNAME: postgres
7+
SCHEDULER_DB_DBNAME: postgres
68
SCHEDULER_DB_HOSTNAME: postgres
9+
SCHEDULER_DB_PORT: 5432
710
SCHEDULER_DB_PG_PASSWORD: super-secret-password
8-
SCHEDULER_DB_DBNAME: postgres
911
volumes:
1012
- ./:/app
1113
depends_on:

reset_db.bash

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
#!/bin/bash
2-
31
# Set variables
42
username=$SCHEDULER_DB_USERNAME
53
dbname=$SCHEDULER_DB_DBNAME
64
hostname=$SCHEDULER_DB_HOSTNAME
75
port=$SCHEDULER_DB_PORT
86
filename="src/create_tables.sql"
97

10-
PG_PASSWORD=$SCHEDULER_DB_PG_PASSWORD
8+
export PGPASSWORD=$SCHEDULER_DB_PG_PASSWORD
119
# Connect to PostgreSQL and execute SQL file
1210
psql -U "$username" -h "$hostname" -p "$port" -d "$dbname" -f "$filename"

src/db.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,4 @@ def assign_grafana_user_permissions(cur: cursor):
172172
cmd = sql.SQL(
173173
"GRANT SELECT ON ALL TABLES IN SCHEMA public TO {};"
174174
).format(sql.Identifier(grafana_username))
175-
cur.execute(cmd)
176-
177-
if __name__ == "__main__":
178-
if "create_tables" in sys.argv:
179-
cur, conn = connect_to_db()
180-
create_tables(cur)
175+
cur.execute(cmd)

0 commit comments

Comments
 (0)