https://github.com/yakubique/upsert-postgresql
Upsert anything to PostgreSQL
https://github.com/yakubique/upsert-postgresql
github-actions insert postgresql sql update upsert
Last synced: 3 months ago
JSON representation
Upsert anything to PostgreSQL
- Host: GitHub
- URL: https://github.com/yakubique/upsert-postgresql
- Owner: yakubique
- License: mit
- Created: 2024-02-28T11:16:37.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-22T11:44:59.000Z (about 2 years ago)
- Last Synced: 2025-01-25T14:25:26.005Z (about 1 year ago)
- Topics: github-actions, insert, postgresql, sql, update, upsert
- Language: TypeScript
- Homepage:
- Size: 229 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Upsert to PostgreSQL
[](./badges/coverage.svg)
[](https://github.com/yakubique/upsert-postgresql/actions/workflows/test-myself.yaml)
Upsert anything to PostgreSQL
[Usage workflow](https://github.com/yakubique/upsert-postgresql/actions/workflows/test-myself.yaml)
Insert or update provided JSON array (_or file with JSON array_) to database. Conflicts would be resolved
by `column_to_match`
## Usage
```yaml
- name: Upsert
id: upsert
uses: yakubique/upsert-postgresql@v1.3
with:
input: |
[{ "id": 1, "value": "c", "test": 1 }, { "id": 2, "value": "b", "test": 2 }]
host: ${{ env.PG_HOST }}
port: ${{ env.PG_PORT }}
username: ${{ env.PG_USER }}
password: ${{ env.PG_PWD }}
db: ${{ env.PG_DB }}
ssl: 'false'
column_to_match: 'id'
table_name: 'test'
```
## Inputs
| INPUT | TYPE | REQUIRED | DEFAULT | DESCRIPTION |
|-----------------|--------|----------|------------|---------------------------------------------------------------------------------------|
| input | string | true | | Input JSON/file |
| db | string | true | | PostgreSQL db |
| host | string | true | | PostgreSQL host |
| password | string | true | | PostgreSQL password |
| username | string | true | | PostgreSQL username |
| port | string | true | `"5432"` | PostgreSQL port (default: 5432) |
| table_name | string | true | | Name of table to upsert |
| column_to_match | string | true | | Primary column to match records (possible to pass multiple columns, comma separated) |
| table_schema | string | false | `"public"` | Table schema to upsert (default: 'public') |
| ssl | string | false | `"true"` | SSL enabled (default: 'true') |
| to_file | string | false | `"false"` | Save result to file (default: 'false') |
| from_file | string | false | `"false"` | Read query from file (default: 'false') |
## Outputs
| OUTPUT | TYPE | DESCRIPTION |
|--------|--------|---------------------|
| count | string | Upserted rows count |
----
[](https://ko-fi.com/S6S1UZ9P7)