diff --git a/.dockerignore b/.dockerignore index 1ff1066..2c2e26f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -11,3 +11,4 @@ query_db.sh **/*.pyc Dockerfile docker-compose.yml +/block_dump_* \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3b59775..d91b356 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ databases/ env/ .bash_history .cache/ +/block_dump_* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 5e9e13a..b51a6e0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3-alpine +FROM python:3.10-alpine LABEL maintainer="Christian Mehlmauer " RUN adduser -h /app -g app -D app diff --git a/Readme.md b/Readme.md index 77c71e6..b16ca53 100644 --- a/Readme.md +++ b/Readme.md @@ -27,7 +27,7 @@ docker pull firefart/network_info docker run --rm firefart/network_info -c postgresql://user:pass@db:5432/network_info ``` -Or cou can connect the docker container to another database container. +Or you can connect the docker container to another database container. ```sh docker run --name network_info_db -e POSTGRES_DB=network_info -e POSTGRES_USER=network_info -e POSTGRES_PASSWORD=network_info -d postgres:9-alpine @@ -222,3 +222,11 @@ created | last_modified | 2008-09-04 06:51:49 source | apnic ``` + +# Export block table + +If you need to export data from PG to another source (Clickhouse, Elasticsearch, etc.) you can use: +``` +./bin/export_to_gzip. +``` +A compressed CSV file will be created. \ No newline at end of file diff --git a/bin/export_to_gzip b/bin/export_to_gzip new file mode 100644 index 0000000..5d0feb1 --- /dev/null +++ b/bin/export_to_gzip @@ -0,0 +1,5 @@ +#!/bin/bash + +docker rm -f dumper +docker-compose run -e PGPASSWORD=network_info --name dumper --entrypoint=psql db -h db -U network_info -e -q -x -c "copy block TO stdout DELIMITER ';' CSV HEADER ;" network_info | gzip > ./block_dump_`date +"%Y-%m-%d"`.csv.gz +docker rm -f dumper