import configparser


def get_db_url(file: str = "creds.ini") -> str:
    """Gets Postgres URL including credentials from specified file.

    Example of File:
    ```
    [pg_creds]
    pg_url = postgresql://testusr:password@127.0.0.1:5432/testdb
    ```
    :param file name
    :returns str or None if exception failed
    """
    try:

        config = configparser.ConfigParser()
        config.read(file)

        mongo_section = config["db"]
        return mongo_section["db_url"]
    except KeyError:
        print("Failed to retrieve database url. Check if {} exists".format(file))
        return ''