https://github.com/peeeuzin/pgbulk
A library for populate large amounts of data to PostgreSQL database with TypeScript
https://github.com/peeeuzin/pgbulk
bulk-insert nodejs postgresql sql typescript
Last synced: about 2 months ago
JSON representation
A library for populate large amounts of data to PostgreSQL database with TypeScript
- Host: GitHub
- URL: https://github.com/peeeuzin/pgbulk
- Owner: peeeuzin
- License: mit
- Created: 2025-02-03T14:20:15.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-03-19T21:35:31.000Z (2 months ago)
- Last Synced: 2025-04-10T00:16:13.223Z (about 2 months ago)
- Topics: bulk-insert, nodejs, postgresql, sql, typescript
- Language: TypeScript
- Homepage:
- Size: 254 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pgbulk
[](https://github.com/peeeuzin/pgbulk/blob/main/LICENSE)
[](https://github.com/peeeuzin/pgbulk/pulls)## 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:
```bash
# npm
npm install pgbulk# yarn
yarn add pgbulk# pnpm
pnpm add pgbulk
```## Example
```ts
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("");
await usersPopulate.start();
await usersPopulate.finish();
```