question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

connection strings not working in 6.x

See original GitHub issue

Moving from v5.1 to v6.x, the same connection strings no longer work.

This used to work up until v5.1 at least:

var cn = "postgres://postgres@localhost:5433/newone";
pg.connect(cn,...)

Now with v6.1, calling:

var cn = "postgres://postgres@localhost:5433/newone";
var pool = new pg.Pool(cn);
pool.connect(function (err, client, done) {

throws the following error:

{ error: database "Vitaly" does not exist
    at Connection.parseE (D:\NodeJS\tests\node_modules\pg\lib\connection.js:543:11)                                                                                 at Connection.parseMessage (D:\NodeJS\tests\node_modules\pg\lib\connection.js:370:17)
    at Socket.<anonymous> (D:\NodeJS\tests\node_modules\pg\lib\connection.js:109:22)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)                                                at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)                            at TCP.onread (net.js:543:20)
  name: 'error',                                                                  length: 107,
  severity: 'FATAL',
  code: '3D000',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'src\\backend\\utils\\init\\postinit.c',
  line: '775',
  routine: 'InitPostgres' }

I had to explicitly switch to the config object to make it work:

var cn = {
    database: 'newone',
    port: 5433,
    host: 'localhost',
    user: 'postgres'
};

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:29 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
Globikcommented, Oct 18, 2016

But why database Vitaly does not exist?

2reactions
KyleLillycommented, Oct 27, 2016

Since pg-pool expects a config object and pool-factory.js was simply passing the argument directly to pg-pool it seems like checking if the passed in options are a string and parsing them into an object is all that was needed. I’ve created a PR but it seems the Travis build is having issues (I have the same issues running locally off master).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Connection String not working - MSDN
I have a data layer that contains table adapters and they use another connection string that is stored in 'app.config', so i changed...
Read more >
Config connection string in .net core 6
NET 6, I recognize that Startup and Program classes are merged into one class. And the above code is not usable in .NET...
Read more >
SQL Server connection strings - ConnectionStrings.com
Connection strings for SQL Server. Connect using Microsoft.Data.SqlClient, SqlConnection, MSOLEDBSQL, SQLNCLI11 OLEDB, SQLNCLI10 OLEDB, SQLNCLI OLEDB.
Read more >
Why Does My ConfigurationManager Connection String Not ...
If you are having trouble getting a connection string to read from your configuration file, check this out.Common Error: Object reference ...
Read more >
Connection String URI Format
If the connection string does not specify a database/ you must specify a slash ( / ) between the last host and the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found