initial commit
This commit is contained in:
commit
6150895b86
9 changed files with 945 additions and 0 deletions
21
config.py
Normal file
21
config.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# https://www.postgresqltutorial.com/postgresql-python/connect/
|
||||
|
||||
from configparser import ConfigParser
|
||||
|
||||
def config(cf='database.ini', section='postgresql'):
|
||||
parser = ConfigParser()
|
||||
parser.read(cf)
|
||||
|
||||
# get section, default to postgresql
|
||||
db = {}
|
||||
if parser.has_section(section):
|
||||
params = parser.items(section)
|
||||
for param in params:
|
||||
db[param[0]] = param[1]
|
||||
else:
|
||||
raise Exception('Section {0} not found in the {1} file'.format(section, filename))
|
||||
|
||||
return db
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue