{"id":43447,"library":"node-pg-connection-pool","title":"node-pg-connection-pool","description":"Connection pool for node-postgres built on top of generic-pool providing simplified query execution and raw connection management. Version 0.9.1 is the latest stable release. It supports ES6 features like Promises, Maps, and Sets, requiring Node >=4. The library offers a seamless interface for running queries without manually managing connections, while also allowing direct access to raw pg clients via acquire/release. It is configurable with pgOptions (for node-postgres client parameters) and poolOptions (for generic-pool configuration), and optionally supports native pg bindings. It is an alternative to other pooling solutions like pg-pool, but is less actively maintained.","status":"maintenance","version":"0.9.1","language":"javascript","source_language":"en","source_url":"https://github.com/pasupulaphani/node-pg-connection-pool","tags":["javascript","pg","postgres","pool","database","node-pool","Connection-pool","generic-pool"],"install":[{"cmd":"npm install node-pg-connection-pool","lang":"bash","label":"npm"},{"cmd":"yarn add node-pg-connection-pool","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-pg-connection-pool","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for PostgreSQL communication; exports the Client class.","package":"pg","optional":true},{"reason":"Used for underlying connection pool implementation.","package":"generic-pool","optional":false}],"imports":[{"note":"This package is CommonJS only; does not support ES modules natively.","wrong":"import PgPool from 'node-pg-connection-pool'","symbol":"PgPool","correct":"const PgPool = require('node-pg-connection-pool')"},{"note":"No named exports; the module exports a single constructor function. Incorrect destructuring may cause undefined.","symbol":"PgPool","correct":"const { default: PgPool } = require('node-pg-connection-pool').default"},{"note":"The module exports a single default export, not named 'Pool'.","wrong":"const { Pool } = require('node-pg-connection-pool')","symbol":"default","correct":"const PgPool = require('node-pg-connection-pool')"}],"quickstart":{"code":"const PgPool = require('node-pg-connection-pool');\n\n// Create a pool with connection options\nconst pool = new PgPool({\n  pgOptions: {\n    host: process.env.PGHOST || 'localhost',\n    port: parseInt(process.env.PGPORT || '5432', 10),\n    database: process.env.PGDATABASE || 'test',\n    user: process.env.PGUSER || 'postgres',\n    password: process.env.PGPASSWORD || ''\n  },\n  poolOptions: {\n    min: 2,\n    max: 10\n  }\n});\n\n// Quick query using async/await\nasync function run() {\n  try {\n    const result = await pool.query('SELECT $1::int AS number', [42]);\n    console.log(result.rows);\n  } catch (err) {\n    console.error(err);\n  } finally {\n    pool.drain().then(() => pool.destroyAllNow());\n  }\n}\nrun();","lang":"javascript","description":"Shows creating a pool with custom configuration, running a parameterized query, and draining the pool."},"warnings":[{"fix":"Access result.rows for the rows array; other properties like command, rowCount are not available.","message":"Pool.query returns rows directly, not the full result object like pg.Client.query","severity":"gotcha","affected_versions":">=0.x"},{"fix":"Use a try...finally block to ensure release() is called even on error.","message":"release() must be called exactly once per acquired client, otherwise pool leaks","severity":"gotcha","affected_versions":">=0.x"},{"fix":"Implement application-level retry logic or use a more robust pool like pg-pool.","message":"The pool does not handle automatic reconnection; failed connections are not retried","severity":"gotcha","affected_versions":">=0.x"},{"fix":"Omit the name option; it has no behavior.","message":"The 'name' option for naming pools is not used internally","severity":"deprecated","affected_versions":">=0.x"},{"fix":"Skip pgNative: true unless you really need native bindings and have build tools installed.","message":"pgNative option requires installing pg-native, which often causes build issues","severity":"deprecated","affected_versions":">=0.x"},{"fix":"Use pool.acquire(), then client.query('BEGIN'), etc., then release.","message":"Pool.query does not support transactions; use acquire() to manage transactions manually","severity":"gotcha","affected_versions":">=0.x"}],"env_vars":null,"search_vec":"'0.9.1':28 '4':45 'access':63 'acquire/release':69 'activ':109 'allow':61 'also':60 'altern':97 'bind':93 'built':12 'client':67,79 'configur':72,87 'connect':4,6,25,58,120 'connection-pool':119 'databas':115 'direct':62 'es6':36 'execut':22 'featur':37 'generic':17,85,123 'generic-pool':16,84,122 'interfac':51 'javascript':111 'latest':31 'less':108 'librari':47 'like':38,102 'maintain':110 'manag':26,57 'manual':56 'map':40 'nativ':91 'node':2,10,44,77,117 'node-pg-connection-pool':1 'node-pool':116 'node-postgr':9,76 'offer':48 'option':89 'paramet':80 'pg':3,66,92,104,112 'pg-pool':103 'pgoption':74 'pool':5,7,18,86,100,105,114,118,121,124 'poolopt':82 'postgr':11,78,113 'promis':39 'provid':19 'queri':21,54 'raw':24,65 'releas':33 'requir':43 'run':53 'seamless':50 'set':42 'simplifi':20 'solut':101 'stabl':32 'support':35,90 'top':14 'version':27 'via':68 'without':55","created_at":"2026-06-05T16:59:50.720482+00:00","updated_at":"2026-06-05T16:59:50.720482+00:00","problems":[{"fix":"Run 'npm install node-pg-connection-pool' in your project root.","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'node-pg-connection-pool'"},{"fix":"Use 'const PgPool = require(\"node-pg-connection-pool\");' and instantiate with 'new PgPool(...)'.","cause":"Incorrect import or using wrong object (e.g., destructuring Pool).","error":"TypeError: pool.query is not a function"},{"fix":"Change the port in pgOptions or kill the other process.","cause":"Another process (e.g., another pool or postgres instance) is using the port.","error":"Error: listen EADDRINUSE: address already in use :::5432"},{"fix":"Start PostgreSQL service or check connection parameters.","cause":"PostgreSQL server is not running or not accessible at that host/port.","error":"Error: connect ECONNREFUSED 127.0.0.1:5432"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/pasupulaphani/node-pg-connection-pool#readme","github":"https://github.com/pasupulaphani/node-pg-connection-pool","docs":null,"changelog":null,"pypi":null,"npm":"node-pg-connection-pool","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}