Quickly export an Excel Workbook to a Postgres DB
Using NPM:
npm i excel-to-postgres
Using Yarn:
yarn add excel-to-postgres
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
});
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)
This package's tests are written using Jest. To execute, run:
npm test