Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt database connection creator #123

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dataprocessing/eGo_data_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import time
import os
import codecs
from tools import io
from dataprocessing.tools import io

def data_processing():
# Configure logging
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion dataprocessing/eGo_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion dataprocessing/python_scripts/ego_dp_loadarea_peakload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
12 changes: 6 additions & 6 deletions dataprocessing/tools/io.py
Original file line number Diff line number Diff line change
@@ -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: ',
Expand Down