Skip to content

🐘 A Node package that allows you to spawn a Postgresql cluster programatically.

License

Notifications You must be signed in to change notification settings

mpranjic/embedded-postgres

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

98 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Embedded Postgres

npm npm type definitions npm NPM

🐘 A Node package that spawns PostgresQL clusters programatically.

Installation

embedded-postgres is available from NPM:

npm i embedded-postgres

Usage

This package contains a simple API that allows you to create clusters, start them, create / delete database and stop any existing processes.

import EmbeddedPostgres from 'embedded-postgres';

async function main() {
    // Create the object
    const pg = new EmbeddedPostgres({
        data_dir: './data/db',
        user: 'postgres',
        password: 'password',
        port: 5432,
        persistent: true,
    });

    // Create the cluster config files
    await pg.initialise();

    // Start the server
    await pg.start();

    // Create and/or drop database
    await pg.createDatabase('TEST');
    await pg.dropDatabase('TEST');

    // Initialize a node-postgres client
    const client = pg.getPgClient();
    await client.connect();
    const result = await client.query('SELECT datname FROM pg_database');

    // Stop the server
    await pg.stop();
}

main();

PostgresQL Versions

This package aims to track the PostgresQL support policy for supported versions. Additionally, we track the binaries that are created upstream in zonky's embedded-postgres-binaries. This leads to the following current support matrix:

Platform / Architecture 11.20.0 12.15.0 13.11.0 14.8.0 15.3.0
🍎 Darwin / x64 βœ… βœ… βœ… βœ… βœ…
🍎 Darwin / arm64[1] 🚫 🚫 🚫 🚫 βœ…
πŸͺŸ Windows / x64 βœ… βœ… βœ… βœ… βœ…
🐧 Linux / x64 βœ… βœ… βœ… βœ… βœ…
🐧 Linux / arm βœ… βœ… βœ… βœ… βœ…
🐧 Linux / arm64 βœ… βœ… βœ… βœ… βœ…
🐧 Linux / ia32 βœ… βœ… βœ… βœ… βœ…
🐧 Linux / ppc64 βœ… βœ… βœ… βœ… βœ…

In order to install a particular version, look for the latest tag in NPM. For example, if you would like to install v10.20.0, you can currently use the following tag:

npm i embedded-postgres@10.20.0-beta.6

Installing particular versions of PostgresQL (i.e. versions not released on NPM) is currently not possible. If you would have a need for doing so, please create an issue.


Contributing

This package is open to issues, feedback, ideas and pull requests. Create an issue on this repository to get started!


Credits and Licensing

Embedded Postgres was created by Lei Nelissen for BMD Studio. It is based on zonky's embedded-postgres-binaries. The binaries are made available under the Apache License 2.0, whereas the specific code in this package is made available under the MIT license.

BMD Studio

About

🐘 A Node package that allows you to spawn a Postgresql cluster programatically.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 50.9%
  • JavaScript 49.1%