Forums

"Table not found" only while running Task

I have a Flask application that emails a summary of a SQLite database (named "timesheet") to a user. Run manually this works absolutely fine, though as soon as I try to create a scheduled Task for it, I get this error in the Task log:

Traceback (most recent call last):
  File "/home/0710160/brpts/export.py", line 28, in <module>
    all_timesheets = pd.read_sql_table(
  File "/usr/local/lib/python3.9/site-packages/pandas/io/sql.py", line 271, in read_sql_table
    raise ValueError(f"Table {table_name} not found") from err
ValueError: Table timesheet not found

The only suggestion I've found online is that it's case-sensitive, but my database is already lowercase. What would be the difference between running manually and running automatically as a Task?

If it's any help, I'm initiating my database connection like this:

db = create_engine("sqlite:///timesheet.sqlite3")

You're using a relative path for your database file without paying attention to the working directory. See https://help.pythonanywhere.com/pages/NoSuchFileOrDirectory/

Thanks glenn! You know, funnily enough, it did occur to me yesterday that this could be the case, but then I never tested it out.