Created
July 19, 2023 17:00
-
-
Save jamiew/e71d7ee1257336dff4ed875a2c73b976 to your computer and use it in GitHub Desktop.
import Helium denylist data into postgres data (e.g. on DeWi ETL)
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
#!/bin/bash | |
# import helium denylist data from github to a local postgres table | |
url="https://raw.githubusercontent.com/helium/denylist/main/denylist.csv" | |
csv="/tmp/denylist.csv" | |
db="etl" | |
echo "downloading from $url ..." | |
curl -s "$url" > "$csv" | |
echo "saved to $csv. file has $(cat $csv | wc -l) rows" | |
# need to drop table first since postgres COPY FROM can't ignore duplicates | |
echo 'DROP TABLE "denylist"' | psql $db | |
echo 'CREATE TABLE "denylist" ( | |
"address" text NOT NULL, | |
PRIMARY KEY ("address") | |
);' | psql $db | |
echo "COPY denylist (address) FROM '/tmp/denylist.csv';" | psql $db | |
echo "denylist table count:" | |
echo 'select count(*) from denylist' | psql $db |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment