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.port,
charset="utf8",
use_unicode=True,
)
- Error : GlobalHydra is already initialized, call GlobalHydra.instance().clear() if you want to re-initialize
Once GlobalHydra initialized, it doesn't need to initialize again. So in my case, I removed it.
#initialize(config_path="./", strict=False)
'Basic Python > Workbook' 카테고리의 다른 글
Latitude VS Longitude (0) | 2023.06.05 |
---|---|
How to preprocess the article to be neat with Regular Expression (0) | 2022.11.24 |
simple way to merge list (0) | 2022.11.22 |
Seperate 2D array to nested list (0) | 2022.05.16 |