title: sqlite3 "OperationalError: unable to open database file" in python only when I deploy my flask app in apache2 or nginx
body: <p>I made an app in flask that uses an sqlite3 database. The app works flawlessly when I run it using Flask's internal testing server. However, when I attempt to deploy my app, either using apache2 or gunicorn+nginx, and the logs of whatever server I'm using shows "OperationalError: unable to open database file".</p>
  
  <p>Here is the full file that's causing the error:</p>
  
  <pre><code>import sqlite3
  
  __all__ = ['Database']
  
  class Database(object):
  
      def __init__(self, name):
          self._name = name
  
      def _execute(self, command, args=None):
          connection = sqlite3.connect(self._name)
          cursor = connection.cursor()
  
          if args is None:
              out = cursor.execute(command).fetchall()
          else:
              out = cursor.execute(command, args).fetchall()
  
          connection.commit()
          connection.close()
          return out
  </code></pre>
  
  <p>The <code>connection = sqlite3.connect(self._name)</code> is the line that is actually triggering the error and I have no clue why. I have tried replacing <code>self._name</code> with a hard coded string to the path of the database to no avail. I have also made sure the database file has proper read write permissions.</p>
  
  <p>Does anyone know how I can figure out what's going on?</p>