diff --git a/dataprocessing/eGo_data_processing.py b/dataprocessing/eGo_data_processing.py index 4421bfff..3f9e79a0 100644 --- a/dataprocessing/eGo_data_processing.py +++ b/dataprocessing/eGo_data_processing.py @@ -14,7 +14,7 @@ import time import os import codecs -from tools import io +from dataprocessing.tools import io def data_processing(): # Configure logging @@ -115,12 +115,12 @@ def data_processing(): # # ## VERSIONING - 'ego_dp_versioning.sql' # Versioning + # 'ego_dp_versioning.sql' # Versioning ] # get database connection - conn = io.oedb_session(section='oedb') + conn = io.oedb_session(section='oep') # iterate over list of sql- and python-snippets and execute them for snippet in snippets: diff --git a/dataprocessing/eGo_preprocessing.py b/dataprocessing/eGo_preprocessing.py index b97234ce..082fbbbc 100644 --- a/dataprocessing/eGo_preprocessing.py +++ b/dataprocessing/eGo_preprocessing.py @@ -42,7 +42,7 @@ def preprocessing(): snippets = ['ego_pre_slp_parameters.sql'] # get database connection - conn = io.oedb_session(section='oedb') + conn = io.oedb_session(section='oep') # iterate over list of sql- and python-snippets and execute them for snippet in snippets: diff --git a/dataprocessing/python_scripts/ego_dp_loadarea_peakload.py b/dataprocessing/python_scripts/ego_dp_loadarea_peakload.py index f24a9c62..5b991053 100755 --- a/dataprocessing/python_scripts/ego_dp_loadarea_peakload.py +++ b/dataprocessing/python_scripts/ego_dp_loadarea_peakload.py @@ -113,7 +113,7 @@ def add_sectoral_peak_load(load_areas, **kwargs): holidays = dict(cal.holidays(2011)) # get database connection object - conn = io.oedb_session(section='oedb') + conn = io.oedb_session(section='oep') Session = sessionmaker(bind=conn) session = Session() diff --git a/dataprocessing/python_scripts/ego_dp_powerflow_griddistrict_demand.py b/dataprocessing/python_scripts/ego_dp_powerflow_griddistrict_demand.py index d1657e1f..b5986ed4 100644 --- a/dataprocessing/python_scripts/ego_dp_powerflow_griddistrict_demand.py +++ b/dataprocessing/python_scripts/ego_dp_powerflow_griddistrict_demand.py @@ -46,7 +46,7 @@ def demand_per_mv_grid_district(): # retrieve sectoral demand from oedb # get database connection - conn = io.oedb_session(section='oedb') + conn = io.oedb_session(section='oep') Session = sessionmaker(bind=conn) session = Session() diff --git a/dataprocessing/tools/io.py b/dataprocessing/tools/io.py index e1cbbb75..44df3282 100644 --- a/dataprocessing/tools/io.py +++ b/dataprocessing/tools/io.py @@ -1,22 +1,22 @@ from sqlalchemy import create_engine +from egoio.tools.db import connection import getpass import sys -def oedb_session(section='oedb'): +def oedb_session(section='oep'): """Get SQLAlchemy session object with valid connection to OEDB""" - # get session object by oemof.db tools (requires .oemof/config.ini + # get session object by oemof.db tools (requires ~/.egoio/config.ini) try: - from oemof import db - conn = db.connection(section=section) + conn = connection(section=section) except: print('Please provide connection parameters to database:\n' + - 'Hit [Enter] to take defaults') + 'Hit [Enter] to take defaults') host = input('host (default 141.44.24.88): ') or 'oe.iws.cs.ovgu.de' port = input('port (default 5432): ') or '5432' - database = input("database name (default 'oedb'): ") or 'oedb' + database = input("database name (default 'oep'): ") or 'oep' user = input('user (default postgres): ') # password = input('password: ') password = getpass.getpass(prompt='password: ',