title: how to access pre-existing table from sqlite using python flask
body: <p>i'm trying by using below code but gives error. </p>
  
  <pre><code>from flask import Flask
  from flask_sqlalchemy import SQLAlchemy
  from flask_restless import APIManager
  
  app = Flask(__name__)
  app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///compData.db'
  db = SQLAlchemy(app)
  db.Model.metadata.reflect(db.engine)
  
  class getRecord(db.Model):
      __table__ = db.Model.metadata.tables['condition']
  
  @app.route('/sample', methods=["GET"])
  def home():
      b = getRecord.query.all()
      for usr in b:
          return usr.first_name
  
  if __name__ == "__main__":
      app.run(debug=True)
  </code></pre>
  
  <p>TraceBack :</p>
  
  <pre><code>    Traceback (most recent call last):
    File "path\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevd.py", line 1596, in &lt;module&gt;
      globals = debugger.run(setup['file'], None, None, is_module)
    File "path\JetBrains\PyCharm Community Edition 2016.3\helpers\pydev\pydevd.py", line 974, in run
      pydev_imports.execfile(file, globals, locals)  # execute the script
    File "path/PycharmProjects/testGetConn/test.py", line 17, in &lt;module&gt;
      class conda(db.Model):
    File "path/PycharmProjects/testGetConn/test.py", line 18, in conda
      __table__ = db.Model.metadata.tables['condition']
  KeyError: 'condition'
  </code></pre>
  
  <p>by using this <a href="http://radar.oreilly.com/2014/05/building-restful-apis-with-flask-in-pycharm.html" rel="nofollow noreferrer">tutorial</a> i have created table using SQLAlchemy on that table above code working fine but when i'm trying to access from another DB it show error.</p>