PostgreSQL
 SQL >> Datenbank >  >> RDS >> PostgreSQL

psql-Rückgabewert/Fehler beendet das aufrufende Shell-Skript?

ON_ERROR_STOP funktioniert nicht zusammen mit der Option -c.

Außerdem sieht das $(...) um das psql seltsam aus – wollen Sie die Ausgabe wirklich als Befehl ausführen?

Und schließlich fehlt ein Backslash nach der Option -L.

Versuchen Sie stattdessen ein „here document“:

psql \ -X \ $POSTGRES_CONNECTION_STRING \ -w \ -b \ -L ./output.txt \ -A \ -q \ --set ON_ERROR_STOP=on \ -t <<EOF \copy mytable(...) from '$input_file' csv HEADER EOF echo "import is done"