psql: PostgreSQL shell

Description Usage Arguments Details Author(s) See Also


Run PostgreSQL's psql shell interactively


psql(psql_opts = "")



a character string passed to the psql command


The psql function repeatedly queries for input and pipes it to PostgreSQL's psql command. It will terminate on \q or empty input.

If psql_opts is an empty string, then an attempt will be made to supply suitable options based on the current connection. If there is no active connection, psql will fallback to complied in defaults. If psql_opts is not an empty string, then it will be passed as-is to psql.

You can type psql's escape commands as usual. Try \?. You cannot use \e or \ef to evoke an editor. Doing strange things with \! will likely hang the R session.

There is no way to direclty enter a database password. If one is required, you can use a password file or set_conn_defaults.

Unfortunately it is probably impossible to enable GNU readline support so for example up-arrow will recall your R commands, not the psql commands entered. You can always call psql from a terminal.


Timothy H. Keitt

See Also


rpg documentation built on May 2, 2019, 5:14 a.m.