nchah / github-traffic-stats

Get statistics on web traffic to your GitHub repositories.
https://pypi.org/project/github-traffic-stats/
121 stars 31 forks source link

relation "repo_overview" does not exist #25

Open gieldemeulemeester opened 3 years ago

gieldemeulemeester commented 3 years ago

I'm trying to log GitHub traffic to a dockerized PostgreSQL database with this service definition in docker-compose:

postgres:
  image: postgres
  environment:
    - POSTGRES_DB=github-traffic-stats
    - POSTGRES_USER=postgres
    - POSTGRES_PASSWORD=<magic password>
  volumes:
    - ./volumes/postgres/data:/var/lib/postgresql/data
  restart: always

I'm running github-traffic-stats in a docker container as well, with this service definition in docker-compose:

github-traffic-stats:
  build: ./services/github-traffic-stats
  depends_on:
    - postgres
  environment:
    - GITHUB_USER=gieldemeulemeester
    - GITHUB_TOKEN=<magic token>
    - POSTGRES_HOST=postgres
    - POSTGRES_PORT=5432
    - POSTGRES_DB=github-traffic-stats
    - POSTGRES_USER=postgres
    - POSTGRES_PASSWORD=<magic password>
  restart: unless-stopped

The environment variables above are used for the entrypoint of the container:

python main.py $GITHUB_USER:$GITHUB_TOKEN "ALL" "set_db" --host $POSTGRES_HOST:$POSTGRES_PORT --db-user $POSTGRES_USER:$POSTGRES_PASSWORD --db-name $POSTGRES_DB

However, github-traffic-stats throws an exception relation "repo_overview" does not exist.

Traceback (most recent call last): File "main.py", line 406, in main err_msg = repos_json.json().get('message') AttributeError: 'list' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "main.py", line 467, in main() File "main.py", line 436, in main store_db(db_config, repo, traffic_response, 'views') File "main.py", line 258, in store_db repo_overview_insert(cur, repo, response_type, json_response) File "main.py", line 273, in repo_overview_insert cur.execute(check_count % (repo, response_type)) psycopg2.ProgrammingError: relation "repo_overview" does not exist LINE 1: SELECT COUNT(*) FROM repo_overview WHERE create_timestamp=DA...

Do I need to initialize the database in some way (create tables, ...)? What am I doing wrong?