Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added gzip-dumper; updated readme #28

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ query_db.sh
**/*.pyc
Dockerfile
docker-compose.yml
/block_dump_*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ databases/
env/
.bash_history
.cache/
/block_dump_*
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3-alpine
FROM python:3.10-alpine
LABEL maintainer="Christian Mehlmauer <[email protected]>"

RUN adduser -h /app -g app -D app
Expand Down
10 changes: 9 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
5 changes: 5 additions & 0 deletions bin/export_to_gzip
Original file line number Diff line number Diff line change
@@ -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