title: OperationalError no such table in Flask with SQLAlchemy
body: <p>run.py</p>
  
  <pre><code>if __name__ == '__main__':
      config() 
      app.run()
  </code></pre>
  
  <p>main.py</p>
  
  <pre><code>import database
  
  app = Flask(__name__)
  
  def config():
      app.config.from_object('config.DevConfig')
  
      # Run SQLAlchemy _that uses app.config_ and add entities if in DEBUG mode
      database.init_db(app)
  
      import blueprints.auth
      app.register_blueprint(blueprints.auth.auth)
  </code></pre>
  
  <p>database.py</p>
  
  <pre><code>db = None
  
  def init_db(app):
      global db
      db = SQLAlchemy(app)
  
      from models import User, Interest, Event
  
      if app.config['DEBUG']:
          print 'Recreating all db'
          db.create_all() # I DO create everything
          print 'Loading test data'
          ... (here I add some Users and etc. and everything works fine - tests pass)
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>from database import db
  
  class User(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      username = db.Column(db.String(80), unique=True)
      email = db.Column(db.String(120), unique=True)
  ...
  </code></pre>
  
  <p>blueprints/auth.py</p>
  
  <pre><code>from models import User
  
  auth = Blueprint('auth', __name__)
  
  @auth.route('/')
  def index():
      return str(User.query.get(1).interests)
  </code></pre>
  
  <p>And so I get</p>
  
  <pre><code>OperationalError: (OperationalError) no such table: user u'SELECT user.id AS user_id, user.username AS user_username, user.email AS user_email, user.passhash AS user_passhash, user.vk_page AS user_vk_page \nFROM user \nWHERE user.id = ?' (1,)
  </code></pre>
  
  <p>What am I doing wrong?</p>