1

модернизация настроек БД

This commit is contained in:
DmitriyMX 2023-05-05 14:25:30 +03:00
parent 267151f546
commit 27797f35a3
No known key found for this signature in database
GPG Key ID: 83F1834955147B6F
3 changed files with 14 additions and 7 deletions

View File

@ -1,6 +1,13 @@
[postgresql]
[export]
host=localhost
port=5432
database=ss14
user=ss14_user
password=ss14_password
[import]
host=localhost
port=6432
database=ss14
user=ss14_user
password=ss14_password

View File

@ -14,13 +14,13 @@ def read_config() -> dict[str, str]:
parser.read("database.ini")
db = {}
if parser.has_section("postgresql"):
params = parser.items("postgresql")
if parser.has_section("export"):
params = parser.items("export")
for param in params:
db[param[0]] = param[1]
else:
raise ParseConfig(
'Section {0} not found in the {1} file'.format("postgresql",
'Section {0} not found in the {1} file'.format("export",
"database.ini"))
return db

View File

@ -18,13 +18,13 @@ def read_config() -> dict[str, str]:
parser.read("database.ini")
db = {}
if parser.has_section("postgresql"):
params = parser.items("postgresql")
if parser.has_section("import"):
params = parser.items("import")
for param in params:
db[param[0]] = param[1]
else:
raise ParseConfig(
'Section {0} not found in the {1} file'.format("postgresql",
'Section {0} not found in the {1} file'.format("import",
"database.ini"))
return db