Python-Flask - How to access sqlite database.db on pythonanywhere.com without specifying its directory? Python-Flask - How to access sqlite database.db on pythonanywhere.com without specifying its directory? database database

Python-Flask - How to access sqlite database.db on pythonanywhere.com without specifying its directory?


In your db file, try this way:

from os import pathROOT = path.dirname(path.realpath(__file__))...db = sqlite3.connect(path.join(ROOT, "database.db"))...

Instead of directly pointing out the path, the ROOT always point to the directory of your file that contains the db, then you should get the right location for your database.