Skip to content

Commit

Permalink
Update postgres connection method
Browse files Browse the repository at this point in the history
Password with a reserved character can break the connection if using url
  • Loading branch information
CannonLock committed Aug 21, 2023
1 parent 036922b commit d246a89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions v1/larkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ var mysql = require("mysql"),
const nameMapping = credentials.postgresDatabases ?? {}
const dbName = nameMapping[db] ?? db

const cfg = "postgres://" + credentials.pg.user + (credentials.pg.password.length ? ':' + credentials.pg.password : '') + "@" + credentials.pg.host + ":" + credentials.pg.port + "/" + dbName;
const pool = new pg.Pool({ connectionString: cfg });
const pool = new pg.Pool({
user: credentials.pg.user,
password: credentials.pg.password,
host: credentials.pg.host,
port: credentials.pg.port,
database: dbName
});

pool.connect(function(err, client, done) {
if (err) {
Expand Down
9 changes: 7 additions & 2 deletions v2/larkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,13 @@ var mysql = require("mysql"),
const nameMapping = credentials.postgresDatabases ?? {}
const dbName = nameMapping[db] ?? db

const cfg = "postgres://" + credentials.pg.user + (credentials.pg.password.length ? ':' + credentials.pg.password : '') + "@" + credentials.pg.host + ":" + credentials.pg.port + "/" + dbName;
const pool = new pg.Pool({ connectionString: cfg });
const pool = new pg.Pool({
user: credentials.pg.user,
password: credentials.pg.password,
host: credentials.pg.host,
port: credentials.pg.port,
database: dbName
});

pool.connect(function(err, client, done) {
if (err) {
Expand Down

0 comments on commit d246a89

Please sign in to comment.