{"id":23821355,"url":"https://github.com/returnstring/pgpromise","last_synced_at":"2026-05-08T06:35:24.897Z","repository":{"id":147346301,"uuid":"135834654","full_name":"returnString/pgpromise","owner":"returnString","description":"Promisified async PostgreSQL queries for R","archived":false,"fork":false,"pushed_at":"2018-06-07T22:54:08.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-02T08:40:12.768Z","etag":null,"topics":["data-engineering","data-science","postgresql","r"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/returnString.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-02T16:37:59.000Z","updated_at":"2019-03-28T13:48:51.000Z","dependencies_parsed_at":"2023-07-07T06:31:45.153Z","dependency_job_id":null,"html_url":"https://github.com/returnString/pgpromise","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/returnString%2Fpgpromise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/returnString%2Fpgpromise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/returnString%2Fpgpromise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/returnString%2Fpgpromise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/returnString","download_url":"https://codeload.github.com/returnString/pgpromise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240102416,"owners_count":19748009,"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":["data-engineering","data-science","postgresql","r"],"created_at":"2025-01-02T08:39:12.231Z","updated_at":"2025-10-06T23:21:53.547Z","avatar_url":"https://github.com/returnString.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pgpromise\nPromisified async PostgreSQL queries for R.\n\n## Motivation\nTypically, querying a database in R implies blocking the current thread of execution. In most cases, this is perfectly acceptable; after all, we're waiting on a result, and have no work to be doing in the interim. However, for use cases like multi-user dashboards, it's often desirable to simultaneously service N clients, e.g. many users loading various pages on a Shiny dashboard, each of which requires DB queries. The classic strategy then has an impact on the user experience, as a single long-running query from one user can delay page loads for others. Really, whilst those long-running queries are being handled on the DB server, we should be running all the remaining CPU-bound work for our dashboard.\n\nFortunately, thanks to the excellent work of the RStudio team, the concept of [promises](https://github.com/rstudio/promises) now exists in R programming, and Shiny has already been updated to take advantage of this. This package implements promise-based queries for PostgreSQL, allowing you to issue queries to PostgreSQL itself (or any wire-protocol compatible DB, e.g. Amazon Redshift) and have the results delivered asynchronously.\n\nAt present, this package is only designed to work with queries generated by `dbplyr`.\n\n## Example\n```R\nlibrary(dplyr)\nlibrary(promises)\nlibrary(pgpromise)\n\nconn \u003c- create_postgres_pool(\n\t# these arguments are mostly just straightforward connection settings\n\thost = \"your-postgres-server\",\n\tport = 5432,\n\tdb = \"superimportantolapdb\",\n\tuser = \"dashboarduser\",\n\tpassword = \"dashboardpw\",\n\t# workers dictates the number of connections used:\n\t# if you issue more simultaneous queries than this,\n\t# then they'll just be queued until a worker becomes available\n\tworkers = 8\n)\n\nitem_sales \u003c- tbl(conn, \"item_sales\")\nitem_sales %\u003e%\n\tfilter(timestamp \u003e= '2018-01-01') %\u003e%\n\tgroup_by(sku) %\u003e%\n\tsummarise(total_revenue = sum(price)) %\u003e%\n\tcollect_async() %...\u003e% # note the promise pipe operator!\n\t{\n\t\tprint(\"2: this will, in fact, be printed second, when we have the results\")\n\t\tprint(.)\n\t}\n\t\nprint(\"1: this will be printed first, before the query completes\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freturnstring%2Fpgpromise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freturnstring%2Fpgpromise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freturnstring%2Fpgpromise/lists"}