nicobrenner / commandjobs

Command Jobs uses AI to help software engineers find the best jobs
Apache License 2.0
146 stars 12 forks source link

Initialize db if it doesn't exist instead of throwing an error #41

Closed hammadfauz closed 3 months ago

hammadfauz commented 3 months ago

running docker-compose -f ./docker/docker-compose.yml run app gives me the following output:

Traceback (most recent call last): 
  File "/commandjobs/src/menu.py", line 429, in <module>
    curses.wrapper(main)
  File "/usr/local/lib/python3.12/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds) 
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/commandjobs/src/menu.py", line 425, in main
    app = MenuApp(stdscr, logger) 
          ^^^^^^^^^^^^^^^^^^^^^^^
  File "/commandjobs/src/menu.py", line 54, in __init__
    self.db_manager = DatabaseManager(self.db_path)  # Specify the path
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/commandjobs/src/database_manager.py", line 6, in __init__
    self.conn = sqlite3.connect(db_path) 
                ^^^^^^^^^^^^^^^^^^^^^^^^ 
sqlite3.OperationalError: unable to open database file

I can see the path to database file in the .env file, but that path does not exist by default. I created repo/job_listings.db in the base directory of the repo, but the error remains.

here is what I did:

mkdir repo
touch repo/job_listings.db
docker-compose -f docker/docker-compose.yml build
docker-compose -f docker/docker-compose.yml run app
nicobrenner commented 3 months ago

Hello @hammadfauz, thank you for reporting this. Sorry about that. You are right, the app should just use a default db name and initialize it

Recently did some changes on the paths and forgot to update the config/sample.env file with the proper ones

Just pushed this PR that fixes it https://github.com/nicobrenner/commandjobs/pull/42

You could git pull on your local repo and copy the sample.env file again, or if you prefer, you can just manually remove the /repo/ part of the path of the BASE_RESUME and DB_PATH variables

image