I'm wondering if there's a way to import PostgreSQL dump through R (RPostgreSQL) into a PostgreSQL database.
I understand this is the way we write csv or a datatable from R into PostgreSQL through RPostgreSQL.
dbWriteTable(con, 'mtcars', mtcars)
This is the way we can import the dump into PostgreSQL database in the terminal.
\i /Users/Downloads/mypostgres.dump
Is there a way I can import the dump into PostgreSQL through a R package, so I don't have to leave the R interface?
You could use system
and call psql
:
system('psql my_new_db < /Users/Downloads/mypostgres.dump')