'Table not found PythonAnywhere
I am trying to access a table within a .db file using sqlite3 in Python Anywhere. The code works properly when I run it locally, but it doesn't work when I host it on the website. Here is the code.
con = sqlite3.connect("/home/routsiddharth/mysite/finance.db", check_same_thread=False)
con.row_factory = sqlite3.Row
cur = con.cursor()
cur.execute(f"SELECT * FROM users WHERE username = '{username}'")
The error I am getting is below.
2022-04-28 04:35:41,871: Exception on /login [POST]
#033[33mTraceback (most recent call last):#033[0m
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2051, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1501, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1499, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1485, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/home/routsiddharth/mysite/app.py", line 194, in login
rows = reformat(cur.execute(f"SELECT * FROM users WHERE username = '{username}'"), "users")
#033[33msqlite3.OperationalError: no such table: users#033[0m
Where is the problem?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
