Skip to content

Instantly share code, notes, and snippets.

@jamiew
Created July 19, 2023 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiew/e71d7ee1257336dff4ed875a2c73b976 to your computer and use it in GitHub Desktop.
Save jamiew/e71d7ee1257336dff4ed875a2c73b976 to your computer and use it in GitHub Desktop.
import Helium denylist data into postgres data (e.g. on DeWi ETL)
#!/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