#Postgres variable key invalid in another service

5 messages · Page 1 of 1 (latest)

prisma scarabBOT
#

Project ID: 3930b8f5-a31f-481b-a979-923bd16c0df9

digital root
#

3930b8f5-a31f-481b-a979-923bd16c0df9

#

Ok I just realized I had to input it here, but the variable when printed still is empty

digital root
#
DB_PORT = os.environ['PG_PORT']
DB_NAME = os.environ['PG_NAME']
DB_USER = os.environ['PG_USER']
DB_PASS = os.environ['PG_PASSWORD']


# Initialize connection pool
db_pool = pool.SimpleConnectionPool(
    minconn=1,      # Minimum number of connections in the pool
    maxconn=10,     # Maximum number of connections in the pool
    host=DB_HOST,
    port=DB_PORT,
    dbname=DB_NAME,
    user=DB_USER,
    password=DB_PASS
)``` 
i decided to just add the variables into the service, but I get this error when trying to connect to the postgres db:
#

    conn = psycopg2.connect(*self._args, **self._kwargs)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/opt/venv/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect

    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

psycopg2.OperationalError: could not translate host name "postgres.railway.internal" to address: Name or service not known```