Код: Выделить всё
db:
image: postgres:latest
container_name: postgres_container
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: voting
networks:
- app
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
- "5433:5433"
healthcheck:
test: [ "CMD", "pg_isready", "-U", "postgres" ]
interval: 10s
timeout: 5s
retries: 5
Код: Выделить всё
engine = create_tables_for_voting.create_tables("postgresql+psycopg2://postgres:postgres123@db:5433/voting")
Session = sessionmaker(bind=engine)
session = Session()
Код: Выделить всё
There was an error when connection to db: (psycopg2.OperationalError) could not translate host name "db" to address: No such host is known.
Код: Выделить всё
There was an error when connection to db: (psycopg2.OperationalError) connection to server at "localhost" (::1), port 5433 failed: server closed the connection unexpectedly This probably means the server terminated abnormally
Я занимался этим часами, если кто-нибудь может мне помочь.
Подробнее здесь: https://stackoverflow.com/questions/789 ... the-server