Closed nonword closed 6 years ago
I succeeded using pooling and pg-native
this way:
import pg from 'pg';
const pool = new pg.Pool({
user: 'user',
password: 'pass',
host: 'localhost',
port: 5432,
database: 'database',
Client: pg.native.Client
});
Could you connect with the following?
const Pool = require('pg-pool');
const config = require('config')
const pool = new Pool({
connectionString: config.get('pg.url')
});
I can't reproduce on latest versions of pg-native/pg-pool - nor using versions contemporaneous with the original issue - so I'm going to close this. Sorry for the noise. Thanks!
I'm trying to use this with pg-native and finding that clients aren't connecting to the connection properties I'm passing in. They instead fall back on environmental variables.
I can see that pg-pool passes the connection hash to the Client constructor, but passes nothing but a
cb
to the connect method. Pg-native expects connection config in the latter. Furthermore, it expects it as a string, following the libpq convention.Should I pass in a custom create handler so that I control how (pg-native) clients are created? Or is there a better solution?
My test script:
Note: Commenting out
Client: require('pg-native'),
causes it to succeed.