skip to Main Content

Problem connecting to the PostgresSQL from Docker

Sample from class: try: conn = psycopg2.connect( database='ytbstatsdb', host='127.0.0.1', user='admin', password='admin123', port='5432' ) except psycopg2.Error as e: print(e) cursor = conn.cursor() engine = sqlalchemy.create_engine('postgresql://admin:admin123@localhost:5432/ytbstatsdb') df_videos_details.to_sql('testtable', engine, if_exists='replace', index=False) Docker file (docker-compose.yaml): services: db: image: postgres ports: - 5432:5432 restart: always…

VIEW QUESTION
Back To Top
Search