Skip to content

Quickly export an Excel Workbook to a Postgres DB

License

Notifications You must be signed in to change notification settings

emotilla/excel-to-postgres

 
 

Repository files navigation

excel-to-postgres

Quickly export an Excel Workbook to a Postgres DB

Installation

Using NPM:

npm i excel-to-postgres

Using Yarn:

yarn add excel-to-postgres

Usage

import { excelToPostgresDb } from 'excel-to-postgres';

excelToPostgresDb({
    host: 'localhost',
    user: 'username',
    password: 'secret',
    port: 5432
    database: 'my_pg_db',
}, '/path/to/file.xlsx',
    {
        createDatabase: true
    });

Options

Supports four options, all of which are optional:

  • createDatabase - true | false (Defaults to false)
  • createTables - true | false (Defaults to false)
  • dropTables - true | false (Defaults to false. When creating table, drop the table if it already exists)
  • generatePrimaryKey - true | false (Defaults to false. Generates 'id' column to be used as a primary key. Cannot be used with 'useExistingPrimaryKeys' option)
  • useExistingPrimaryKeys - true | false (Defaults to false. Supports multiple primary keys. Append '_pk' to the column name in the workbook that will be the primary key. Cannot be used with 'generatePrimaryKey' option)

Testing

This package's tests are written using Jest. To execute, run:

npm test

About

Quickly export an Excel Workbook to a Postgres DB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.9%
  • Other 1.1%