-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindexExchConfig.py
More file actions
41 lines (35 loc) · 1.11 KB
/
indexExchConfig.py
File metadata and controls
41 lines (35 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""
By: Drew Reid
Date: May 2, 2015
Purpose:
class to parse the Config File
"""
#import the configparser
from configparser import ConfigParser
class db_Config:
parser = None
def __init__(self, configFile):
self.parser = ConfigParser()
self.parser.read(configFile)
#read the databse connection details
def read_db_Conn(self, section='mySQL'):
db = {}
if self.parser.has_section(section):
items = self.parser.items(section)
for item in items:
db[item[0]] = item[1]
else:
raise Exception("{0} not found in the {1} file".format(section, self.file))
return db
#read the path to the databse upload file
def read_db_Path(self, section='dbPath'):
if self.parser.has_section(section):
return self.parser.get(section, 'path')
else:
raise Exception("{0} not found in the {1} file".format(section, self.file))
#get the database upload file name
def read_db_File(self, section='dbPath'):
if self.parser.has_section(section):
return self.parser.get(section, 'file')
else:
raise Exception("{0} not found in the {1} file".format(section, self.file))