# pgtools

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

Latest version **1.0.1** (published 2023-08-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install pgtools
pnpm add pgtools
yarn add pgtools
bun add pgtools
```

Provides the commands `dropdbjs`, `createdbjs`.

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-08-09 |
| First published | 2015-07-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 76 |
| Author | Olivier Lalonde |
| Maintainers | olalonde, bcoe, adriaanvanrossum |
| Keywords | postgres, postrgresql, createdb, dropdb, knex |

## Links

- npm: https://www.npmjs.com/package/pgtools
- Repository: https://github.com/olalonde/pgtools
- Homepage: https://github.com/olalonde/pgtools#readme
- Issues: https://github.com/olalonde/pgtools/issues
- npm.io page: https://npm.io/package/pgtools

## Dependencies (3)

- [pg](https://npm.io/package/pg.md) ^8.9.0
- [yargs](https://npm.io/package/yargs.md) ^17.7.1
- [pg-connection-string](https://npm.io/package/pg-connection-string.md) ^2.5.0

## Recent versions

- 1.0.1 (latest) — 2023-08-09
- 1.0.0-2 (alpha) — 2023-02-25
- 1.0.0 — 2023-02-25
- 1.0.0-1 — 2023-02-25
- 1.0.0-0 — 2023-02-25
- 0.3.2 — 2021-06-02
- 0.3.1 — 2021-03-02
- 0.3.0 — 2017-07-24
- 0.2.3 — 2016-11-27
- 0.2.2 — 2016-09-24
- 0.2.1 — 2016-09-24
- 0.2.0 — 2016-09-14
- 0.1.1 — 2016-05-12
- 0.1.0 — 2016-05-12
- 0.0.2 — 2015-09-21
- … 1 more at https://npm.io/package/pgtools/versions

## README

# pgtools

[![Build
Status](https://github.com/olalonde/pgtools/actions/workflows/nodejs.yml/badge.svg)](https://github.com/olalonde/pgtools/actions/workflows/nodejs.yml)
[![Coverage Status](https://coveralls.io/repos/github/olalonde/pgtools/badge.svg?branch=master)](https://coveralls.io/github/olalonde/pgtools?branch=master)

Pure Node.js implementation of PostgreSQL's
[createdb](https://www.postgresql.org/docs/current/app-createdb.html)
and
[dropdb](https://www.postgresql.org/docs/current/app-dropdb.html)
tools.

Only supports connection options and database name at the moment.

## Install

```bash
npm install --save -g pgtools
```

## CLI Example

```bash
createdbjs my_awesome_db --user=admin --password=admin
```

## Library Example

```javascript
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

```typescript
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](./scr/index.d.ts) for types.

See [pg documentation](https://node-postgres.com/apis/client) for `ConnectionConfig` format.

More usage examples in [./src/test.js](./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.

---
_Source: https://npm.io/package/pgtools · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
