{"id":18521,"library":"machinepack-postgresql","title":"Machinepack PostgreSQL","description":"Structured Node.js bindings for connecting to and running queries against a PostgreSQL database. Version 4.0.2 is the latest stable release. It is part of the Sails.js ecosystem and implements the Waterline Driver Interface. Release cadence is irregular; primarily maintained for legacy Sails applications. Key differentiators: uses machine definitions for structured operations, integrates with Sails' Waterline ORM, wraps the `pg` driver. Unmaintained since 2017; prefer `pg` directly or newer Waterline adapters.","status":"maintenance","version":"4.0.2","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/sailshq/machinepack-postgresql","tags":["javascript","postgresql","driver","waterline","sails","machines","machinepack"],"install":[{"cmd":"npm install machinepack-postgresql","lang":"bash","label":"npm"},{"cmd":"yarn add machinepack-postgresql","lang":"bash","label":"yarn"},{"cmd":"pnpm add machinepack-postgresql","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core PostgreSQL driver","package":"pg","optional":false},{"reason":"Defines machinepack structure","package":"machine","optional":false}],"imports":[{"note":"ESM import works but the package is CJS-only; use require for compatibility.","wrong":"const MPPostgresql = require('machinepack-postgresql')","symbol":"default","correct":"import MPPostgresql from 'machinepack-postgresql'"},{"note":"Named exports are not available; use the default export object.","wrong":"import { getConnection } from 'machinepack-postgresql'","symbol":"getConnection","correct":"var MPPostgresql = require('machinepack-postgresql');\nMPPostgresql.getConnection({...}).exec(...)"},{"note":"Methods are on the default export, not separately exported.","wrong":"const sendQuery = require('machinepack-postgresql').sendQuery","symbol":"sendQuery","correct":"var MPPostgresql = require('machinepack-postgresql');\nMPPostgresql.sendQuery({...}).exec(...)"}],"quickstart":{"code":"var MPPostgresql = require('machinepack-postgresql');\n\n// Get a connection\nMPPostgresql.getConnection({\n  host: 'localhost',\n  port: 5432,\n  user: 'postgres',\n  password: process.env.PGPASSWORD || '',\n  database: 'mydb'\n}).exec({\n  error: function(err) { console.log('Error:', err); },\n  success: function(connection) {\n    // Send a query\n    MPPostgresql.sendQuery({\n      connection: connection,\n      query: 'SELECT * FROM users LIMIT 1'\n    }).exec({\n      error: function(err) { console.log('Query error:', err); },\n      success: function(result) {\n        console.log('Result:', result);\n        MPPostgresql.releaseConnection({ connection: connection }).exec();\n      }\n    });\n  }\n});","lang":"javascript","description":"Connects to a PostgreSQL database, runs a SELECT query, and releases the connection using machinepack-postgresql's structured bindings."},"warnings":[{"fix":"Migrate to 'pg' (npm install pg) or 'sails-postgresql' for Sails apps.","message":"This package is no longer actively maintained. Use the 'pg' package directly or a modern Waterline adapter like 'sails-postgresql'.","severity":"deprecated","affected_versions":">=4.0.0"},{"fix":"Always call MPPostgresql.releaseConnection() after queries, or use a connection pool wrapper.","message":"The connection object must be released manually. Forgetting to release can exhaust connection pool.","severity":"gotcha","affected_versions":"*"},{"fix":"Call .exec() with callback or error/success exits. Alternatively, promisify with util.promisify.","message":"All method calls use the machinepack pattern with .exec(), not Promises. This is unlike many modern Node.js libraries.","severity":"gotcha","affected_versions":"*"},{"fix":"Check the Waterline Driver Interface for supported options; use 'pg' directly for advanced features.","message":"The package wraps 'pg' but exposes a different API. Direct 'pg' configuration options may not be passed through.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure PostgreSQL is running: sudo service postgresql start (Linux) or brew services start postgresql (macOS).","cause":"PostgreSQL server is not running or not accessible at the specified host/port.","error":"Error: connect ECONNREFUSED 127.0.0.1:5432"},{"fix":"Set correct password in connection or configure pg_hba.conf to allow trust for local connections.","cause":"Incorrect password or missing pg_hba.conf configuration.","error":"error: password authentication failed for user \"postgres\""},{"fix":"Use const MPPostgresql = require('machinepack-postgresql'); then call MPPostgresql.getConnection(...).","cause":"Importing the module incorrectly, e.g., using named import or destructuring.","error":"TypeError: MPPostgresql.getConnection is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}