Forums

sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) file is encrypted or is not a database

Hi,

I have received the above error while trying to run a Flask app. The app pulls a dataset from a sqlite3 databse. I've been troubleshooting this for most of the day and have seen the other two forums on this same error message but haven't been able to fix my issue.

I've ensured I'm using an absolute filepath to the db and I've tried to check that both Python and PythonAnywhere are using the same version of SQLite3 after seeing this pop up on StackOverflow and elsewhere. Because of this, I made sure to try creating the db file through the PythonAnywhere Bash console to avoid any potential version mismatches but it didn't work.

Here's how I'm trying to access the database:

engine = create_engine("sqlite:////home/ryanfox212/disaster-response-classification/data/DisasterResponse.db")
df = pd.read_sql_table("messages", engine)

I've been enjoying hosting on PythonAnywhere after switching from Heroku but connecting to db through SQLAlchemy has been a nightmare. Any help is appreciated and please do check my error logs if this helps to troubleshoot.

It looks like you have one slash too many in the address -- try sqlite:///home... instead of what you have right now. The second thing worth checking is if you can interact with the database in a different way, e.g. through sqlite command line.