PythonでINIとDBを読み取る
前回のつづき。データ取得の実装。
成果物
使い方はGitHub参照。
ライブラリ
データ取得には以下のライブラリを使用した。
| 項目 | ライブラリ |
|---|---|
| INI | configparser |
| DB | dataset |
configparser
INIファイルのキー値を参照できるのがステキ。
[GitHub]
Username=user1
[SSH]
Host=github.com.${GitHub:Username}
from configparser import ConfigParser, ExtendedInterpolation self.config = ConfigParser(interpolation=ExtendedInterpolation()) self.config.read(self.file_path_config) print(self.config['SSH']['Host'])
実行結果は以下。
github.com.user1
所感
今回取得した値を前回の標準入出力と結合させる。