title: How can I create a table if not exist on Flask with SQLAlchemy?
body: <p>I am using SQLAlchemy and I have the following code:</p>
  <p>Model:</p>
  <pre><code>class User(db.Model):
      __tablename__ = 'user'
      __table_args__ = {'schema': 'task', 'useexisting': True}
      id = Column(Integer, primary_key=True, autoincrement=True)
      firstname = Column(String)
  </code></pre>
  <p>.env</p>
  <pre><code>SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI')
  </code></pre>
  <p>app.py</p>
  <pre><code>def create_app(config_file):
      &quot;&quot;&quot;Create a Flask application using the app factory pattern.&quot;&quot;&quot;
  
      app = Flask(__name__)
  
      &quot;&quot;&quot;Load configuration.&quot;&quot;&quot;
  
      app.config.from_pyfile(config_file)
  
      &quot;&quot;&quot;Init app extensions.&quot;&quot;&quot;
      from .extensions import db
  
      db.init_app(app)
  </code></pre>
  <p>This creates the SQLite file if it does not exist, but not the tables of each model.</p>
  <p>The question is what can I do in order to create the tables for each model?</p>