New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@aux4/db-postgres

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aux4/db-postgres

Database CLI for Postgres

latest
Source
npmnpm
Version
1.0.7
Version published
Maintainers
1
Created
Source

@aux4/db-postgres

JavaScript

Install

$ npm install @aux4/db-postgres

Execute Query

const Database = require("@aux4/db-postgres");
const db = new Database({
  host: "localhost",
  user: "postgres",
  password: "******",
  database: "template1"
});

(async () => {
  await db.open();
  const { data } = await db.execute("select * from table where id = :id", { id: 1 });
  console.log(JSON.stringify(data, null, 2));
  await db.close();
})();

Query Stream

const Database = require("@aux4/db-postgres");
const db = new Database({
  host: "localhost",
  user: "postgres",
  password: "******",
  database: "template1"
});

const stream = await db.stream("select * from table where id = :id", { id: 1 });

stream.on("data", row => {
console.log(JSON.stringify(row, null, 2));
});

stream.on("error", err => {
console.error(err.message);
});

stream.on("close", async () => {
await db.close();
});

Command Line

Install

$ npm install --global @aux4/db
$ npm install --global @aux4/db-postgres

Usage

Execute Query

$ db execute --host localhost --port 5432 --user postgres --database template1 --query "select * from table where id = :id" --id 1

Stream Query

$ db stream --host localhost --port 5432 --user postgres --database template1 --query "select * from table where id = :id" --id 1

Using @aux4/config

create config.yaml

config:
  dev:
    postgres:
      host: localhost
      port: 5432
      user: postgres
      password: "******"
      database: template1
$ db execute --configFile config.yaml --config dev/postgres --query "select * from table where id = :id" --id 1

See Also

  • aux4 website / npm / GitHub
  • @aux4/config npm / GitHub
  • @aux4/db npm / GitHub

Keywords

aux4

FAQs

Package last updated on 23 Aug 2023

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