Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSAMPERE committed Jun 28, 2023
1 parent e360253 commit 384b80c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 31 deletions.
24 changes: 3 additions & 21 deletions _user/db_connections.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
{
"Oracle" : [
{
"connection_name" : "",
"host" : "",
"port" : "",
"database" : "",
"username" : "",
"password" : ""
}
],
"PostgreSQL" : [
{
"connection_name" : "",
"host" : "",
"port" : "",
"database" : "",
"username" : "",
"password" : ""
}
]
}
"Oracle": [],
"PostgreSQL": []
}
31 changes: 21 additions & 10 deletions modules/layer/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,26 +597,25 @@ def build_connection_dict(self, dbms: str, skip_invalid: bool = True):
user_saved = qsettings.value(dbms_prefix + connection_name + "/saveUsername")
connection_service = qsettings.value(dbms_prefix + connection_name + "/service")

# For "traditionnaly" registered connections
if password_saved == "true" and user_saved == "true":
connection_dict = self.qsettings_content_parser(
dbms=dbms, connection_name=connection_name
# For connections configured using config file and service
if connection_service != "" and self.pg_configfile_path and dbms == "PostgreSQL":
connection_dict = self.config_file_parser(
self.pg_configfile_path, connection_service, connection_name
)
if connection_dict[0]:
connection_dict = connection_dict[1]
else:
logger.warning(connection_dict[1])

# For connections configured using config file and service
elif connection_service != "" and self.pg_configfile_path:
connection_dict = self.config_file_parser(
self.pg_configfile_path, connection_service, connection_name
continue
# For "traditionnaly" registered connections
elif password_saved == "true" and user_saved == "true":
connection_dict = self.qsettings_content_parser(
dbms=dbms, connection_name=connection_name
)
if connection_dict[0]:
connection_dict = connection_dict[1]
else:
logger.warning(connection_dict[1])
continue
else:
continue

Expand Down Expand Up @@ -670,6 +669,18 @@ def build_connection_dict(self, dbms: str, skip_invalid: bool = True):
"password": conn_dict.get("password"),
"connection": connection_name,
}
elif all(
conn_dict.get(key, "") == ""
for key in [
"database",
"host",
"port",
"username",
"password",
"connection_name",
]
):
continue
else:
logger.warning(
"Invalid {} connection loaded from db_connections.json file : {}".format(
Expand Down

0 comments on commit 384b80c

Please sign in to comment.