-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable PostgreSQL engine for sql sink (#745)
- Loading branch information
Showing
10 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# PostgreSQL Sink Example | ||
|
||
## Steps | ||
|
||
1. initialize docker compose | ||
|
||
``` | ||
docker-compose up | ||
``` | ||
|
||
2. create required tables | ||
|
||
``` | ||
psql -h localhost -p 5432 -U postgres -f init.sql | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[source] | ||
type = "N2N" | ||
peers = ["relays-new.cardano-mainnet.iohk.io:3001"] | ||
|
||
[intersect] | ||
type = "Point" | ||
value = [114220807, "01822b10afde3d09bd5e72758857b669ddadcdaad6776a3dc8ee902c3ace1d7e"] | ||
|
||
[[filters]] | ||
type = "SplitBlock" | ||
|
||
[sink] | ||
type = "SqlDb" | ||
connection = "postgres://postgres:example@localhost:5432/postgres" | ||
apply_template = "INSERT INTO txs (slot, cbor) VALUES ('{{point.slot}}', decode('{{record.hex}}', 'hex'));" | ||
undo_template = "DELETE FROM txs WHERE slot = {{point.slot}}" | ||
reset_template = "DELETE FROM txs WHERE slot > {{point.slot}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: "3.1" | ||
|
||
services: | ||
db: | ||
image: postgres | ||
# image: mumak | ||
restart: always | ||
environment: | ||
POSTGRES_PASSWORD: example | ||
volumes: | ||
- postgres_db:/var/lib/postgresql/data | ||
ports: | ||
- 5432:5432 | ||
|
||
volumes: | ||
postgres_db: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE TABLE txs ( | ||
slot INTEGER NOT NULL, | ||
cbor BYTEA | ||
); | ||
|
||
CREATE INDEX idx_txs_slot ON txs(slot); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.