Skip to content
Snippets Groups Projects
Commit 1ba9dceb authored by Raphael Sturgis's avatar Raphael Sturgis
Browse files

added get_db_connection in config

parent f84815d3
No related branches found
No related tags found
2 merge requests!12version 0.2a,!10Resolve "Image creation bugs with 0 size windows"
This commit is part of merge request !10. Comments created here will be created in the context of that merge request.
......@@ -8,6 +8,8 @@ import os
from pathlib import Path
from configparser import ConfigParser
import psycopg2
def get_config_file():
"""
......@@ -58,6 +60,7 @@ def get_data_path():
.format(data_path, config_file))
return data_path
def get_db_config():
"""
Read db config from user configuration file.
......@@ -83,3 +86,13 @@ def get_db_config():
raise Exception('Invalid data path: {}. Update configuration file {}'
.format(dict, config_file))
return dict
def get_db_connection():
db_config = get_db_config()
connection = psycopg2.connect(user=db_config['user'],
password=db_config['password'],
host=db_config['host'],
port=db_config['port'],
database=db_config['database'])
return connection
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment