Postgresql komutlarını tek transaction içerisinde çalıştırma
psql \ -X \ -U myuser \ -h myhost \ -f /path/to/sql/file.sql \ --echo-all \ --single-transaction \ --set AUTOCOMMIT=off \ --set ON_ERROR_STOP=on \ mydatabase
sql den gelen sonucu iterate etme
#!/bin/bash set -e set -u PSQL=/usr/bin/psql DB_USER=myuser DB_HOST=myhost DB_NAME=mydb $PSQL \ -X \ -h $DB_HOST \ -U $DB_USER \ -c "select username, password, first_name, last_name from users" \ --single-transaction \ --set AUTOCOMMIT=off \ --set ON_ERROR_STOP=on \ --no-align \ -t \ --field-separator ' ' \ --quiet \ -d $DB_NAME \ | while read username password first_name last_name ; do echo "USER: $username $password $first_name $last_name" done
Hiç yorum yok:
Yorum Gönder