I am trying the CS50 Web Development with Python Course, and in the sql section, while importing create_engine from sqlalchemy I got this error
ImportError: cannot import name 'create_engine' from partially initialized module 'sqlalchemy' (most likely due to a circular import)
Here is the snippet:
DATABASE_URL = "postgres://usrname:password@YourHost:5432/flights"
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
engine = create_engine(DATABASE_URL)
db = scoped_session(sessionmaker(bind=engine))
flights = db.execute("SELECT origin, destination, duration FROM flights").fetchall()
for flight in flights:
print(f"{flight.origin} to {flight.destination}, {flight.duration} minutes.")
Timestamp for the Video: