title: flask db init Error: Could not import "app.run"
body: <p>I am trying to initialise my db, and everytime i run the flask db init command, I get that error.</p>
  
  <p>I am unsure why, my FLASK_APP and FLASK_ENV are set correctly.</p>
  
  <p>I have been reorganising the project structure and file names to abide more with the flask guidelines in the moments before this.</p>
  
  <p>run.py</p>
  
  <pre class="lang-py prettyprint-override"><code>from app import app
  
  app.run(debug=True)
  
  </code></pre>
  
  <p>config.py</p>
  
  <pre class="lang-py prettyprint-override"><code>import os
  
  
  basedir = os.path.abspath(os.path.dirname(__file__))
  SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')
  SQLALCHEMY_TRACK_MODIFICATIONS = True
  
  </code></pre>
  
  <p><strong>init</strong>.py</p>
  
  <pre class="lang-py prettyprint-override"><code>from flask import Flask
  from flask_sqlalchemy import SQLAlchemy
  from flask_migrate import Migrate
  
  
  app = Flask(__name__)
  app.config.from_object('config')
  db = SQLAlchemy(app)
  
  migrate = Migrate(app, db)
  
  from app import views, models
  
  </code></pre>
  
  <p>db_create.py</p>
  
  <pre class="lang-py prettyprint-override"><code>from config import SQLALCHEMY_DATABASE_URI
  from app import db
  import os.path
  
  
  db.create_all()
  
  </code></pre>
  
  <p>models.py</p>
  
  <pre class="lang-py prettyprint-override"><code>from app import db
  
  
  class Property(db.Model):
      id = db.Column(db.Integer, primary_key=True)
      address = db.Column(db.String(500), index=True, unique=True)
      start_date = db.Column(db.DateTime)
      duration = db.Column(db.Integer)
      rent = db.Column(db.Float)
  
  </code></pre>
  
  <p>views.py</p>
  
  <pre class="lang-py prettyprint-override"><code>from app import app
  from flask import render_template
  
  @app.route('/')
  def index():
      return render_template('index.html')
  
  
  </code></pre>
  
  <p>Error:</p>
  
  <p>$ flask db init
  Usage: flask db init [OPTIONS]</p>
  
  <p>Error: Could not import "app.run".</p>
  
  <p>edit: Folder structure so you can understand better:</p>
  
  <pre><code>config.py
  run.py
  app/
      __init__.py
      db_create.py
      models.py
      views.py
      static/
      templates/
          index.html
          layout.html
  </code></pre>
  
  <p>adding again: The issue is not running my code, it is when I am trying to initialise my db using <code>flask db init</code></p>
  
  <p>I get the error in my terminal when trying to run this, hoping someone can help me figure out why and then fix it, thanks for reading :)</p>