{"id":13858155,"url":"https://github.com/r-dbi/RPostgres","last_synced_at":"2025-07-13T23:31:25.987Z","repository":{"id":25395285,"uuid":"28823976","full_name":"r-dbi/RPostgres","owner":"r-dbi","description":"A DBI-compliant interface to PostgreSQL","archived":false,"fork":false,"pushed_at":"2025-05-05T02:21:15.000Z","size":14316,"stargazers_count":337,"open_issues_count":26,"forks_count":79,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-21T06:10:02.330Z","etag":null,"topics":["database","postgres","postgresql","r"],"latest_commit_sha":null,"homepage":"https://rpostgres.r-dbi.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r-dbi.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-01-05T17:43:02.000Z","updated_at":"2025-05-04T02:31:29.000Z","dependencies_parsed_at":"2023-12-20T15:02:10.881Z","dependency_job_id":"d714693f-06dd-489e-8dc3-b65ad78aaa09","html_url":"https://github.com/r-dbi/RPostgres","commit_stats":{"total_commits":1486,"total_committers":47,"mean_commits":"31.617021276595743","dds":0.4528936742934051,"last_synced_commit":"b62bc601a26e1207591027241f44312f18701929"},"previous_names":[],"tags_count":116,"template":false,"template_full_name":null,"purl":"pkg:github/r-dbi/RPostgres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-dbi%2FRPostgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-dbi%2FRPostgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-dbi%2FRPostgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-dbi%2FRPostgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r-dbi","download_url":"https://codeload.github.com/r-dbi/RPostgres/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r-dbi%2FRPostgres/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265220345,"owners_count":23729795,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","postgres","postgresql","r"],"created_at":"2024-08-05T03:01:58.593Z","updated_at":"2025-07-13T23:31:20.975Z","avatar_url":"https://github.com/r-dbi.png","language":"R","funding_links":[],"categories":["R","Database Management","Language bindings"],"sub_categories":[],"readme":"# RPostgres\n\n\u003c!-- badges: start --\u003e\n[![rcc](https://github.com/r-dbi/RPostgres/workflows/rcc/badge.svg)](https://github.com/r-dbi/RPostgres/actions)\n[![Codecov test coverage](https://codecov.io/gh/r-dbi/RPostgres/branch/master/graph/badge.svg)](https://app.codecov.io/gh/r-dbi/RPostgres?branch=main)\n[![CRAN status](https://www.r-pkg.org/badges/version/RPostgres)](https://CRAN.R-project.org/package=RPostgres)\n\u003c!-- badges: end --\u003e\n\nRPostgres is an DBI-compliant interface to the postgres database. It's a ground-up rewrite using C++ and [cpp11](https://github.com/r-lib/cpp11). Compared to RPostgreSQL, it:\n\n* Has full support for parameterised queries via `dbSendQuery()`, and `dbBind()`.\n\n* Automatically cleans up open connections and result sets, ensuring that you\n  don't need to worry about leaking connections or memory.\n\n* Is a little faster, saving ~5 ms per query. (For reference, it takes around 5ms\n  to retrieve a 1000 x 25 result set from a local database, so this is \n  decent speed up for smaller queries.)\n\n* A simplified build process that relies on system libpq.\n\n## Installation\n```R\n# Install the latest RPostgres release from CRAN:\ninstall.packages(\"RPostgres\")\n\n# Or the the development version from GitHub:\n# install.packages(\"remotes\")\nremotes::install_github(\"r-dbi/RPostgres\")\n```\n\nDiscussions associated with DBI and related database packages take place on [R-SIG-DB](https://stat.ethz.ch/mailman/listinfo/r-sig-db). \nThe website [Databases using R](https://db.rstudio.com/) describes the tools and best practices in this ecosystem.\n\n## Basic usage\n\n```R\nlibrary(DBI)\n# Connect to the default postgres database\ncon \u003c- dbConnect(RPostgres::Postgres())\n\ndbListTables(con)\ndbWriteTable(con, \"mtcars\", mtcars)\ndbListTables(con)\n\ndbListFields(con, \"mtcars\")\ndbReadTable(con, \"mtcars\")\n\n# You can fetch all results:\nres \u003c- dbSendQuery(con, \"SELECT * FROM mtcars WHERE cyl = 4\")\ndbFetch(res)\ndbClearResult(res)\n\n# Or a chunk at a time\nres \u003c- dbSendQuery(con, \"SELECT * FROM mtcars WHERE cyl = 4\")\nwhile(!dbHasCompleted(res)){\n  chunk \u003c- dbFetch(res, n = 5)\n  print(nrow(chunk))\n}\n# Clear the result\ndbClearResult(res)\n\n# Disconnect from the database\ndbDisconnect(con)\n```\n## Connecting to a specific Postgres instance\n\n```R\nlibrary(DBI)\n# Connect to a specific postgres database i.e. Heroku\ncon \u003c- dbConnect(RPostgres::Postgres(),dbname = 'DATABASE_NAME', \n                 host = 'HOST', # i.e. 'ec2-54-83-201-96.compute-1.amazonaws.com'\n                 port = 5432, # or any other port specified by your DBA\n                 user = 'USERNAME',\n                 password = 'PASSWORD')\n\n```\n\n## Design notes\n\nThe 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.\n\n---\n\nPlease note that the 'RPostgres' project is released with a\n[Contributor Code of Conduct](https://rpostgres.r-dbi.org/CODE_OF_CONDUCT.html).\nBy contributing to this project, you agree to abide by its terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-dbi%2FRPostgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr-dbi%2FRPostgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr-dbi%2FRPostgres/lists"}