pythonsqlitepython-dataset

How do I get the dataset module for Python to work when deployed?


Locally, I've created an empty sqlite database called earthquakes.db. Using the dataset Python library, I am able to freeze my results to a json file and everything works as expected. However, when deployed I get a long list of errors that presumably refer to being unable to connect to the database.

Traceback (most recent call last):
   File "/var/www/html/apps/earthquakes/scripts/earthquakes.py", line 7, in <module>
       db = dataset.connect('sqlite:///earthquakes.db')

   ... More base.py and pool.py errors here ...

sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file

I've checked permissions and installs, everything seems to be right. What am I missing? Thx.


Solution

  • Noob move. When I gave it the full path in my script, the error went away.

    From this... db = dataset.connect('sqlite:///earthquakes.db')

    To this... db = dataset.connect('sqlite:////var/www/html/apps/earthquakes/scripts/earthquakes.db')