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
Branches
Tags
2 merge requests!12version 0.2a,!10Resolve "Image creation bugs with 0 size windows"
...@@ -8,6 +8,8 @@ import os ...@@ -8,6 +8,8 @@ import os
from pathlib import Path from pathlib import Path
from configparser import ConfigParser from configparser import ConfigParser
import psycopg2
def get_config_file(): def get_config_file():
""" """
...@@ -58,6 +60,7 @@ def get_data_path(): ...@@ -58,6 +60,7 @@ def get_data_path():
.format(data_path, config_file)) .format(data_path, config_file))
return data_path return data_path
def get_db_config(): def get_db_config():
""" """
Read db config from user configuration file. Read db config from user configuration file.
...@@ -83,3 +86,13 @@ def get_db_config(): ...@@ -83,3 +86,13 @@ def get_db_config():
raise Exception('Invalid data path: {}. Update configuration file {}' raise Exception('Invalid data path: {}. Update configuration file {}'
.format(dict, config_file)) .format(dict, config_file))
return dict 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