How to stop a Postgres script when it encounters an error?

I think the solution to add following to .psqlrc is far from perfection \set ON_ERROR_STOP on there exists much more simple and convenient way – use psql with parameter: psql -v ON_ERROR_STOP=1 better to use also -X parameter turning off .psqlrc file usage. Works perfectly for me p.s. the solution found in great post from … Read more

How to solve PostgreSQL pgAdmin error “Server instrumentation not installed” for adminpack?

For current versions of PostgreSQL and pgAdmin, the “Guru” dialog warning has a “Fix it!” button or command. Use it. If there’s no “Fix it!” then we can use the Unix command line as follows. This is for PostgreSQL 9.1. Older versions do it differently. PostgresSQL docs are here: download adminpacks 8.4. adminpack functions 9.1. … Read more

ERROR: missing data for column when using \copy in psql

Three possible causes: One or more lines of your file has only 4 or fewer space characters (your delimiter). One or more space characters have been escaped (inadvertently). Maybe with a backslash at the end of an unquoted value. For the (default) text format you are using, the manual explains: Backslash characters (\) can be … Read more

How to start psql.exe

You don’t run some psql.exe file, but the file C:\Program Files\PostgreSQL\10\scripts\runpsql.bat , for example programmatically, e.g. from AHK: run, “C:\Program Files\PostgreSQL\10\scripts\runpsql.bat” Then you get a generic Windows command window which asks you the right questions (see above) and, when answered correctly, gives you the psql command prompt.

How to print current working directory in psql console?

Typing in the command \! pwd will print the current working directory in psql. To change working directory use command \cd <path>; replace <path> with desired path. Eg. Running command \cd /run/mount will change the current working directory to /run/mount. Try changing the your working directory to that containing the file which you want to … Read more