> while somebody comfortable is shell writes a parallelized one liner
Do you have an example of this? I didn’t even know you could make sql calls in scripts.
Do you have an example of this? I didn’t even know you could make sql calls in scripts.
https://adamdrake.com/command-line-tools-can-be-235x-faster-...
PSQL="psql postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@$DATABASE_HOST:$DATABASE_PORT/$POSTGRES_DB -t -P pager=off -c "
OLD="CURRENT_DATE - INTERVAL '5 years'"
$PSQL "SELECT id from apt WHERE apt.created_on > $OLD order by apt.created_on asc;" | while
read -r id; do
if [[ $id != "" ]]; then
printf "\n\*\* Do something in the loop with id where newer than \"$OLD\" \*\*\*\n"
# ...
fi
doneI don't do much sql in bash scripts but I do keep some wrapper scripts that let me run queries from stdin to databases in my environment