pgtools
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

pgtools

Build Status Coverage Status

Pure Node.js implementation of PostgreSQL's createdb and dropdb tools.

Only supports connection options and database name at the moment.

Install

npm install --save -g pgtools

CLI Example

createdbjs my_awesome_db --user=admin --password=admin

Library Example

const { createdb, dropdb } = require("pgtools");

// This can also be a connection string
// (in which case the database part is ignored and replaced with postgres)

const config = {
  user: "postgres",
  password: "some pass",
  port: 5432,
  host: "localhost",
};

await createdb(config, "test-db");
await dropdb(config, "test-db");

Usage

createdb(config: string | pg.ConnectionConfig, dbname: string): Promise<pg.QueryResult<any>>;
dropdb(config:  string | pg.ConnectionConfig, dbname: string): Promise<pg.QueryResult<any>>;

See ./src/index.d.ts for types.

See pg documentation for ConnectionConfig format.

More usage examples in ./src/test.js.

Bins

pgtools installs two useful binaries:

  • createdbjs: which emulates pgtools' createdb functionality.
  • dropdbjs: which emulates pgtools' dropdb functionality.

Node.js support

We support all LTS versions from 10 and up. We try to keep up with the latest Node.js version.

Package Sidebar

Install

npm i pgtools

Weekly Downloads

13,689

Version

1.0.1

License

MIT

Unpacked Size

12.1 kB

Total Files

13

Last publish

Collaborators

  • olalonde
  • bcoe
  • adriaanvanrossum