我正在用python和JS进行CS50 web开发。我正在听第3课,列表中有这个问题。py:
我在运行它时遇到这个错误我正在用python和JS进行CS50 web开发。我正在听第3课,列表中有这个问题。py:,python,Python,我在运行它时遇到这个错误 import os from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker engine = create_engine("postgresql://postgres:Goodtime80@localhost:5432/flights") db = scoped_session(sessionmaker(bind=en
import os
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
engine = create_engine("postgresql://postgres:Goodtime80@localhost:5432/flights")
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()
您的PostgreSQL server没有名为
flights
的数据库
您确定这是数据库的名称(表的名称很可能是flights
)
您是否创建了数据库(并可能将一些数据导入其中)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL: database "flights" does not exist
(Background on this error at: http://sqlalche.me/e/13/e3q8)