Python Flask SQLite

howescHOBBY

3 months ago

Hi there, hope you can help

My Flask app uses a SQLite database referenced within my application like this:

DB_PATH = './_vol/db.sqlite'

In my Railway app, I've created a volume at /app/_vol.

My Procfile looks like this:

release: python sqlite_db.py

web: gunicorn server:app

The release step is supposed to create the database, but it fails during Build:
sqlite3.OperationalError: unable to open database file

The line that fails is this:

conn = sqlite3.connect(DB_PATH)

Solved

2 Replies

3 months ago

Volume access is not provided at the build step. You should look into using pre deploy commands for this: https://docs.railway.com/guides/pre-deploy-command


Status changed to Awaiting User Response railway[bot] 3 months ago


howescHOBBY

3 months ago

This works, thank you so much


Status changed to Awaiting Railway Response railway[bot] 3 months ago


Status changed to Solved itsrems 3 months ago