Created
May 11, 2017 03:44
-
-
Save Everfighting/db7b5805cb69328dbdc8bb0f90ce17ec to your computer and use it in GitHub Desktop.
读取配置文件转成json连接数据库
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import psycopg2 | |
import json | |
def load_db_config(): | |
with open('../conf/db0.conf', "r") as f: | |
config_json = json.loads(f.read()) | |
return config_json | |
config_json = load_db_config() | |
def handle_conn(): | |
conn = psycopg2.connect(**config_json) | |
return conn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment