Create config.yaml under the same root. Connection: user: root passwd: xxxx db: xxxx host: xxxx port: xxxx And conncect it. from hydra.experimental import compose, initialize initialize(config_path="./", strict=False) cfg = compose("config.yaml") conn = pymysql.connect( user=cfg.Connection.user, passwd=cfg.Connection.passwd, db=cfg.Connection.db, host=cfg.Connection.host, port=cfg.Connection.por..