A DBI-compliant interface to PostgreSQL
RPostgres is an DBI-compliant interface to the postgres database. It's a ground-up rewrite using C++ and Rcpp. Compared to RPostgreSQL, it:
Has full support for parameterised queries via
Automatically cleans up open connections and result sets, ensuring that you don't need to worry about leaking connections or memory.
Is a little faster, saving ~5 ms per query. (For reference, it takes around 5ms to retrieve a 1000 x 25 result set from a local database, so this is decent speed up for smaller queries.)
A simplified build process that relies on system libpq.
# Install the latest RPostgres release from CRAN: install.packages("RPostgres")
Or the the development version from GitHub:
library(DBI) # Connect to the default postgres database con
Connecting to a specific Postgres instancelibrary(DBI) # Connect to a specific postgres database i.e. Heroku con
The original DBI design imagined that each package could instantiate X drivers, with each driver having Y connections and each connection having Z results. This turns out to be too general: a driver has no real state, for PostgreSQL each connection can only have one result set. In the RPostgres package there's only one class on the C side: a connection, which optionally contains a result set. On the R side, the driver class is just a dummy class with no contents (used only for dispatch), and both the connection and result objects point to the same external pointer.
Please note that the 'RPostgres' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.