katefike / sage

A personal finance app that's like Mint, but better. It uses a dockerized postfix/dovecot email server. Parses transaction data from alert emails.
MIT License
5 stars 0 forks source link

Initialize the POSTGRES_USER #132

Closed katefike closed 4 months ago

katefike commented 4 months ago

PROBLEM

SOLUTION

Using a "base" docker-compose.yml with a docker-compose..yml file was the root problem. So I got rid of the "base" docker-compose and now just have two independent docker-compose..yml files. They're a little redundant but the base file introduced too many footguns.

TESTING

DEV

=================================================== 87 passed in 27.01s ====================================================

PROD

2024-05-20 21:01:21.346 | INFO     | __main__:main:28 - STARTING SAGE
2024-05-20 21:01:21.446 | INFO     | __main__:main:77 - UID 5 was not parsed into a transaction.
2024-05-20 21:01:21.451 | INFO     | __main__:main:96 - Total Messages in Batch = 1
2024-05-20 21:01:21.452 | INFO     | __main__:main:97 - {'retrieved': 1, 'unparsed': 1, 'processed': 0}
2024-05-20 21:01:21.452 | INFO     | __main__:main:98 - DONE
(.venv) kfike@prod:~/sage$ docker exec -it  sage-db psql -U admin sage
psql (14.4 (Debian 14.4-1.pgdg110+1))
Type "help" for help.

sage=# 

Successfully received gmail test email

katefike commented 4 months ago

ERROR PROD

(.venv) kfike@prod:~/sage$ cd ~/sage/ &&.venv/bin/python3 -m sage >> ~/sage/cron.log 2>&1
(.venv) kfike@prod:~/sage$ cat cron.log
2024-05-17 21:34:17.790 | INFO     | __main__:main:28 - STARTING SAGE
2024-05-17 21:34:17.884 | CRITICAL | sage.db.execute_statements:open_connection:24 - Failed to connect to the database: connection to server at "localhost" (::1), port 5432 failed: FATAL:  password authentication failed for user "admin"

Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/kfike/sage/sage/__main__.py", line 103, in <module>
    msg_count = main()
  File "/home/kfike/sage/sage/__main__.py", line 72, in main
    email_id = emails.insert_email(email)
  File "/home/kfike/sage/sage/db/emails.py", line 30, in insert_email
    email_id = execute_statements.insert_get_id(stmt, email_data)
  File "/home/kfike/sage/sage/db/execute_statements.py", line 55, in insert_get_id
    with open_connection() as conn:
  File "/home/kfike/sage/sage/db/execute_statements.py", line 25, in open_connection
    raise error
  File "/home/kfike/sage/sage/db/execute_statements.py", line 16, in open_connection
    conn = psycopg2.connect(
  File "/home/kfike/sage/.venv/lib/python3.10/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: FATAL:  password authentication failed for user "example_user"