0

I have been tasked with migrating a python web application to another Linux server. Frustratingly, the entire database is sqlite3. I have moved all related code and database files to the new server and set up the environment. Python does not seem to be able to open the database files as I get this message when running the app:

OperationalError: unable to open database file

I have checked the following:

  • All paths are correct, the database connection is made.
  • Read/Write permission is open to all users on the files for testing

One difference between the servers is, the old server has sqlite 3.5.6 and the new one has 3.6.20. Would there be file compatibility issues here? If so, is there a way to convert the database files to be compatible? Is there another problem I may be overlooking?

Marty
  • 2,104
  • 2
  • 23
  • 42
  • How did you copy the file over to the server? What did you transfer **from**? Some transfer methods can, mistakenly, use line ending translations, replacing Windows `\r\n` line endings with `\n`, unless instructed to transfer in binary mode. – Martijn Pieters Aug 13 '13 at 15:33
  • I made a tarball containing all the code from the app, and extracted it on the new server. The old server is RHEL4, new is CentOS 6 – Marty Aug 13 '13 at 15:34
  • Okay, that's an easy one ruled out then. – Martijn Pieters Aug 13 '13 at 15:34
  • 2
    [Is the directory containing the database file writable](http://serverfault.com/a/57597)? – unutbu Aug 13 '13 at 15:45
  • 1
    Have you checked this thread http://stackoverflow.com/questions/4636970/sqlite3-operationalerror-unable-to-open-database-file? –  Aug 13 '13 at 15:47
  • It may be a mismatch between python sqlite 3 interface and sqlite database. Probably your Python connector does not handle new version of sqlite. To check what sqlite version is supported by your python installation write the following in python: **import sqlite3**, and then **sqlite3.sqlite_version** if you'll get a version which is lower then the one you have installed on server then this may be the cause of error. – Pawel Miech Aug 13 '13 at 15:49

1 Answers1

2

The error message

OperationalError: unable to open database file

may occur if the directory containing the database file is not writable.

To make the directory writeable for $USER:

chmod o+w /path/to/dir
chown $USER /path/to/dir
Community
  • 1
  • 1
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677