Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pgpass

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pgpass

Module for reading .pgpass

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.2M
decreased by-5.88%
Maintainers
1
Weekly downloads
 
Created

What is pgpass?

The pgpass npm package is used to handle PostgreSQL password files (.pgpass) in Node.js applications. It simplifies the process of managing database credentials by reading and parsing the .pgpass file, which stores passwords for PostgreSQL connections.

What are pgpass's main functionalities?

Reading .pgpass file

This feature allows you to read the .pgpass file and retrieve the password for a given connection information. The pgpass function takes connection info and a callback, and returns the password if found.

const pgpass = require('pgpass');
const connInfo = { host: 'localhost', port: 5432, user: 'user', database: 'mydb' };
pgpass(connInfo, (err, password) => {
  if (err) {
    console.error('Error reading .pgpass file:', err);
  } else {
    console.log('Password:', password);
  }
});

Handling multiple entries

This feature demonstrates how to handle multiple entries in the .pgpass file. You can retrieve passwords for different users and databases by providing the respective connection information.

const pgpass = require('pgpass');
const connInfo1 = { host: 'localhost', port: 5432, user: 'user1', database: 'db1' };
const connInfo2 = { host: 'localhost', port: 5432, user: 'user2', database: 'db2' };
pgpass(connInfo1, (err, password1) => {
  if (err) {
    console.error('Error reading .pgpass file for user1:', err);
  } else {
    console.log('Password for user1:', password1);
  }
});
pgpass(connInfo2, (err, password2) => {
  if (err) {
    console.error('Error reading .pgpass file for user2:', err);
  } else {
    console.log('Password for user2:', password2);
  }
});

Other packages similar to pgpass

Keywords

FAQs

Package last updated on 09 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc