#191 postgre - ability to define connection by connection string

This commit is contained in:
Jan Prochazka
2021-11-14 18:45:32 +01:00
parent 1d90cd25c4
commit f68744fba7
2 changed files with 40 additions and 12 deletions

View File

@@ -27,7 +27,7 @@ const drivers = driverBases.map(driverBase => ({
...driverBase,
analyserClass: Analyser,
async connect({ engine, server, port, user, password, database, databaseUrl, ssl }) {
async connect({ engine, server, port, user, password, database, databaseUrl, useDatabaseUrl, ssl }) {
let options = null;
if (engine == 'redshift@dbgate-plugin-postgres') {
@@ -47,15 +47,18 @@ const drivers = driverBases.map(driverBase => ({
connectionString: url,
};
} else {
options = {
// connectionString: 'postgres://root@localhost:26257/postgres?sslmode=disabke'
host: server,
port,
user,
password,
database: database || 'postgres',
ssl,
};
options = useDatabaseUrl
? {
connectionString: databaseUrl,
}
: {
host: server,
port,
user,
password,
database: database || 'postgres',
ssl,
};
}
const client = new pg.Client(options);