import os
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
engine=create_engine(os.getenv("DATABASE_URL"))
db = scoped_session(sessionmaker(bind=engine))
def main():
flights = db.execute("SELECT origin, destination, duration FROM flights").fetchall()
for flight in flights:
print(f"{flight.origin} to {flight.destination}, {flight.duration} minutes.")
if __name__ == "__main__":
main()
Traceback (most recent call last): File "list.py", line 6, in engine=create_engine(os.getenv("DATABASE_URL")) File "C:\Users\Aakash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sqlalchemy\engine__init__.py", line 479, in create_engine return strategy.create(*args, **kwargs) File "C:\Users\Aakash\AppData\Local\Programs\Python\Python38-32\lib\site-packages\sqlalchemy\engine\strategies.py", line 56, in create plugins = u._instantiate_plugins(kwargs) AttributeError: 'NoneType' object has no attribute '_instantiate_plugins'
And if change my code to: