I have two docker containers running by the following commands:
I have created the necessary user, database and table in my postgres (psql) container.
I am trying to run a python script:
import osfrom sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmakerengine = 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()
I get the following error:
File “list.py”, line 6, in <module>
engine = create_engine(os.getenv(“DATABASE_URL”))
File “/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/init.py”, line 435, in create_engine
return strategy.create(*args, **kwargs)
File “/usr/local/lib/python3.6/dist-packages/sqlalchemy/engine/strategies.py”, line 56, in create
plugins = u._instantiate_plugins(kwargs)
I know one issue is that I need to set DATABASE_URL env - but I am not sure what should be that value
#python #docker #postgresql