excel-to-postgres
TypeScript icon, indicating that this package has built-in type declarations

1.6.0 • Public • Published

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

Package Sidebar

Install

npm i excel-to-postgres

Weekly Downloads

37

Version

1.6.0

License

MIT

Unpacked Size

61.8 kB

Total Files

31

Last publish

Collaborators

  • murphyj1011