Support 'password' keyword in configuration files (#343)

* Support 'password' keyword in configuration files

* Update travis-ci
This commit is contained in:
An Tao 2020-02-04 10:58:10 +08:00 committed by GitHub
parent ce675c1b87
commit dd5e8f8159
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 2 deletions

View File

@ -1,7 +1,7 @@
matrix:
include:
- os: linux
dist: bionic
dist: xenial
- os: osx
osx_image: xcode11
@ -48,6 +48,7 @@ before_install:
- cd -
before_script:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then
brew tap homebrew/services;
brew services restart postgresql;
sleep 2;
psql -c 'create user postgres superuser;' postgres;

View File

@ -704,6 +704,10 @@ void create_model::createModel(const std::string &path,
exit(1);
}
auto password = config.get("passwd", "").asString();
if (password.empty())
{
password = config.get("password", "").asString();
}
auto connStr =
utils::formattedString("host=%s port=%u dbname=%s user=%s",

View File

@ -13,7 +13,7 @@
"schema": "public",
//user: User name
"user": "",
//password: Password
//passwd: Password
"passwd": "",
//table: An array of tables to be modelized. if the array is empty, all revealed tables are modelized.
"tables": [],

View File

@ -421,6 +421,10 @@ static void loadDbClients(const Json::Value &dbClients)
}
auto user = client.get("user", "postgres").asString();
auto password = client.get("passwd", "").asString();
if (password.empty())
{
password = client.get("password", "").asString();
}
auto connNum = client.get("connection_number", 1).asUInt();
auto name = client.get("name", "default").asString();
auto filename = client.get("filename", "").asString();