0.4.5 • Published 4 months ago

pgbulk v0.4.5

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

pgbulk

GitHub License GitHub Issues or Pull Requests

What's pgbulk?

A library for bulk inserts into PostgreSQL with TypeScript, you just need to parse it.

Populate can be used for bulk insert CSV files into PostgreSQL with performance.

Installation

You can install the package using npm:

# npm
npm install pgbulk 

# yarn
yarn add pgbulk

# pnpm
pnpm add pgbulk

Example

import { PGBulk } from 'pgbulk';

class Users extends PGBulk {
  constructor(connectionURL: string) {
    super({
      connection: {
        connectionString: connectionURL,
      },
      strategy: "csv",
      tables: {
        users: [
          {
            databaseColumn: "id",
            type: "TEXT",
          },

          {
            databaseColumn: "name",
            type: "TEXT",
          },

          {
            databaseColumn: "nickname",
            csvColumn: "aka",
            type: "TEXT",
          },
        ]
      },
      allowDisableIndexes: true,
      allowDisableForeignKeys: true,
    })

    this.register("pathto/data", "users-*.csv");
  },

  await parse(row: Row) {
    // do some parsing thing
    // ...
    return row
  }
}

const usersPopulate = new Users("<postgres_url>");

await usersPopulate.start();
await usersPopulate.finish();
0.4.5

4 months ago

0.4.4

4 months ago

0.4.3

4 months ago

0.4.2

4 months ago

0.4.1

4 months ago

0.4.0

4 months ago

0.3.2

4 months ago

0.3.1

4 months ago

0.3.0

4 months ago

0.2.2

4 months ago

0.2.1

4 months ago

0.2.0

4 months ago

0.1.1

4 months ago

0.1.0

4 months ago