code: def wait_for_postgres(database, host, port, username, password):
          # type: (Optional[str], Optional[str], Union[int, str, None], Optional[str], Optional[str]) -> None
          
          connecting_string = 'Checking for PostgreSQL...'
          if port is not None:
              port = int(port)
          while True:
              try:
                  logger.info(connecting_string)
                  connection = psycopg2.connect(
                      database=database,
                      host=host,
                      port=port,
                      user=username,
                      password=password,
                      connect_timeout=3
                  )
                  connection.close()
                  logger.info('PostgreSQL is running!')
                  break
              except psycopg2.OperationalError:
                  time.sleep(1)
docs: Waits for PostgreSQL database to be up
  
          Args:
              database (Optional[str]): Database name
              host (Optional[str]): Host where database is located
              port (Union[int, str, None]): Database port
              username (Optional[str]): Username to log into database
              password (Optional[str]): Password to log into database
  
          Returns:
              None