17 lines
405 B
Python
Executable File
17 lines
405 B
Python
Executable File
from configparser import ConfigParser
|
|
|
|
|
|
def read_db_config(filename='../env/config.ini', section='mysql'):
|
|
parser = ConfigParser()
|
|
parser.read(filename)
|
|
|
|
db = {}
|
|
if parser.has_section(section):
|
|
items = parser.items(section)
|
|
for item in items:
|
|
db[item[0]] = item[1]
|
|
else:
|
|
raise Exception(f'{section} not found in the {filename} file')
|
|
|
|
return db
|