File tree Expand file tree Collapse file tree 4 files changed +6
-11
lines changed
Expand file tree Collapse file tree 4 files changed +6
-11
lines changed Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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 :
Original file line number Diff line number Diff line change 1- #! /bin/bash
2-
31# Set variables
42username=$SCHEDULER_DB_USERNAME
53dbname=$SCHEDULER_DB_DBNAME
64hostname=$SCHEDULER_DB_HOSTNAME
75port=$SCHEDULER_DB_PORT
86filename=" 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
1210psql -U " $username " -h " $hostname " -p " $port " -d " $dbname " -f " $filename "
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments