Skip to content

Commit abc3bab

Browse files
authored
Merge pull request #31 from fact-project/database_name
Database name
2 parents 85df6c9 + 97f682d commit abc3bab

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

fact/credentials/__init__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,21 @@ def get_credentials():
4949
return config
5050

5151

52-
def create_factdb_engine():
52+
def create_factdb_engine(database=None):
5353
'''
5454
returns a sqlalchemy.Engine pointing to the factdata database
5555
5656
The different hostname on isdc machines is handled correctly.
5757
'''
58+
spec = 'mysql+pymysql://{user}:{password}@{host}/{database}'
59+
5860
creds = get_credentials()
61+
config = dict(creds['database'])
5962

6063
if socket.gethostname().startswith('isdc'):
61-
spec = 'mysql+pymysql://{user}:{password}@lp-fact/{database}'
62-
else:
63-
spec = 'mysql+pymysql://{user}:{password}@{host}/{database}'
64+
config['host'] = 'lp-fact'
65+
66+
if database is not None:
67+
config['database'] = database
6468

65-
return create_engine(spec.format(**creds['database']))
69+
return create_engine(spec.format(**config))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name='pyfact',
6-
version='0.8.2',
6+
version='0.8.3',
77
description='A module containing useful methods for working with fact',
88
url='http://github.com/fact-project/pyfact',
99
author='Maximilian Noethe, Dominik Neise',

0 commit comments

Comments
 (0)