title: db.create_all() 'NoneType' object has no attribute 'drivername'
body: <p>I am following the CS50's Web Programming with Python and Javascript and in Lecture4 I have had the following error trying to create a postgresql database table:</p>
  
  <pre><code> Traceback (most recent call last):
    File "create.py", line 19, in &lt;module&gt;
      main()
    File "create.py", line 15, in main
      db.create_all()
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 963, in create_all
      self._execute_for_all_tables(app, bind, 'create_all')
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 955, in _execute_for_all_tables
      op(bind=self.get_engine(app, bind), **extra)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 896, in get_engine
      return connector.get_engine()
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 556, in get_engine
      self._sa.apply_driver_hacks(self._app, info, options)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/flask_sqlalchemy/__init__.py", line 830, in apply_driver_hacks
      if info.drivername.startswith('mysql'):
  AttributeError: 'NoneType' object has no attribute 'drivername'
  </code></pre>
  
  <p>The code that I have used is in two python file:
  The first 1 called models.py:</p>
  
  <pre><code>from flask_sqlalchemy import SQLAlchemy
  
  db = SQLAlchemy()
  
  class Flight(db.Model):
      __tablename__ = "flights"
      id = db.Column(db.Integer, primary_key=True)
      origin = db.Column(db.String, nullable=False)
      destination = db.Column(db.String, nullable=False)
      duration = db.Column(db.Integer, nullable=False)
  
  class Passenger(db.Model):
      __tablename__ = "passengers"
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String, nullable=False)
      flight_id = db.Column(db.Integer, db.ForeignKey("flight.id"), nullable=False)
  </code></pre>
  
  <p>The second file is called create.py:</p>
  
  <pre><code>import os
  
  from flask import Flask, render_template, request
  from models import *
  
  app = Flask(__name__)
  app.config["SQLALCHEMY_DATABASE_URI"] = os.getenv("postgresql://postgres:password@localhost/database1")
  app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
  db.init_app(app)
  
  def main():
      db.create_all()
  
  if __name__ == "__main__":
      with app.app_context():
          main()
  </code></pre>
  
  <p>Can you help me?!</p>