Postgres has many convenient "backslash" commands (e.g \dt
, \du
, \l
, etc). I would like to run these via the RPostgresql interface. I have tried the following:
drv = dbDriver("PostgreSQL")
con <- dbConnect(drv,
dbname = "my_database",
host = "**********",
port = ****,
user = "******",
password = "******")
dbExecute(con, "\\dt")
# Close PostgreSQL connection
dbDisconnect(con)
However, I get the following error:
Error in postgresqlExecStatement(conn, statement, ...) :
RS-DBI driver: (could not Retrieve the result : ERROR: syntax error at or
near "\"
LINE 1: \dt
^
)
Is it possible to run these from RPostgresql? Or are backslash commands restricted to command line psql
only?