title: sqlalchemy.exc.OperationalError: (OperationalError) unable to open database file None None
body: <p>I am running a program from another person who are inconvenience ask for help from. The program is a website. Server end is written by python and flask (module, <a href="http://flask.pocoo.org/" rel="noreferrer">http://flask.pocoo.org/</a>). The program has been successfully run on the server. What I need to do is modify something on it. Since the production server is not allowed for test, I tested it in development server locally via flask. However, I could not run even the original program. Below is from python.</p>
  
  <pre><code>(venv)kevin@ubuntu:~/python/public_html$ python index.wsgi 
  </code></pre>
  
  <blockquote>
    <p>Traceback (most recent call last):
        File "index.wsgi", line 6, in 
        from app import app as application</p>
  </blockquote>
  
  <pre><code>File "/home/kevin/python/public_html/app.py", line 27, in &lt;module&gt;
  app = create_app()
  
  File "/home/kevin/python/public_html/app.py", line 12, in create_app
  database.init_db()
  
  File "/home/kevin/python/public_html/database.py", line 24, in init_db
  Base.metadata.create_all(engine)
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/schema.py", line 2793, in create_all
    tables=tables)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1478, in _run_visitor
  with self._optional_conn_ctx_manager(connection) as conn:
  
  File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
  return self.gen.next()
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1471, in _optional_conn_ctx_manager
  with self.contextual_connect() as conn:
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1661, in contextual_connect
  self.pool.connect(),
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 272, in connect
  return _ConnectionFairy(self).checkout()
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 425, in __init__
  rec = self._connection_record = pool._do_get()
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 857, in _do_get
  return self._create_connection()
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 225, in _create_connection
  return _ConnectionRecord(self)
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 318, in __init__
  self.connection = self.__connect()
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/pool.py", line 368, in __connect
  connection = self.__pool._creator()
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/strategies.py", line 80, in connect
  return dialect.connect(*cargs, **cparams)
  
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 283, in connect
  return self.dbapi.connect(*cargs, **cparams)
  
  sqlalchemy.exc.OperationalError: (OperationalError) unable to open database file None None
  </code></pre>
  
  <p>In the config.py file</p>
  
  <blockquote>
    <p>LOGFILE = '/tmp/ate.log'
        DEBUG = True
        TESTING = True
        THREADED = True
        DATABASE_URI = 'sqlite:////tmp/ate.db'
        SECRET_KEY = os.urandom(24)</p>
  </blockquote>
  
  <p>Hence, I created a folder called "tmp" under my user and an empty file called "ate.db". Then, ran it again. It said</p>
  
  <blockquote>
    <p>IOError: [Errno 2] No such file or directory: '/home/kevin/log/ate.log'</p>
  </blockquote>
  
  <p>Then, I created the log folder and the log file. Run it, but nothing happened like</p>
  
  <blockquote>
    <p>(venv)kevin@ubuntu:~/python/public_html$ python index.wsgi 
    (venv)kevin@ubuntu:~/python/public_html$ python index.wsgi 
    (venv)kevin@ubuntu:~/python/public_html$ </p>
  </blockquote>
  
  <p>If it is successful, the website should be available on <code>http://127.0.0.1:5000</code>/. However, it did not work. Does anybody know why and how to solve it? The codes should be fine since it is now available online. The problem should be a local problem. Thank you so much for your help. </p>
  
  <p>The code of where the program is stuck</p>
  
  <pre><code>from sqlalchemy import create_engine
  from sqlalchemy.ext.declarative import declarative_base
  from sqlalchemy.orm import scoped_session, sessionmaker
  
  engine = None
  db_session = None
  Base = declarative_base()
  
  
  def init_engine(uri, **kwards):
      global engine
      engine = create_engine(uri, **kwards)
      return engine
  
  
  def init_db():
      global db_session
      db_session = scoped_session(sessionmaker(bind=engine))
      # import all modules here that might define models so that
      # they will be registered properly on the metadata.  Otherwise
      # you will have to import them first before calling init_db()
      import models
      Base.metadata.create_all(engine)
  </code></pre>