{"id":13834855,"url":"https://github.com/rpolars/r-polarssql","last_synced_at":"2025-07-10T07:30:58.999Z","repository":{"id":206539900,"uuid":"716661101","full_name":"rpolars/r-polarssql","owner":"rpolars","description":"A Polars backend for R DBI and dbplyr","archived":false,"fork":false,"pushed_at":"2025-06-29T08:31:34.000Z","size":5483,"stargazers_count":27,"open_issues_count":5,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-29T09:31:32.598Z","etag":null,"topics":["dplyr","dplyr-sql-backends","polars","r"],"latest_commit_sha":null,"homepage":"https://rpolars.github.io/r-polarssql/","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/rpolars.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2023-11-09T15:50:07.000Z","updated_at":"2025-06-29T08:28:44.000Z","dependencies_parsed_at":"2024-08-22T14:38:35.012Z","dependency_job_id":"cbcfb585-7075-4f68-b74e-b0d725706a31","html_url":"https://github.com/rpolars/r-polarssql","commit_stats":null,"previous_names":["rpolars/r-polarssql"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rpolars/r-polarssql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpolars%2Fr-polarssql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpolars%2Fr-polarssql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpolars%2Fr-polarssql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpolars%2Fr-polarssql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rpolars","download_url":"https://codeload.github.com/rpolars/r-polarssql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rpolars%2Fr-polarssql/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264545157,"owners_count":23625403,"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":["dplyr","dplyr-sql-backends","polars","r"],"created_at":"2024-08-04T14:00:53.053Z","updated_at":"2025-07-10T07:30:58.990Z","avatar_url":"https://github.com/rpolars.png","language":"R","funding_links":[],"categories":["Libraries/Packages/Scripts"],"sub_categories":["R"],"readme":"---\noutput:\n  github_document:\n    html_preview: false\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r}\n#| include: false\n\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# polarssql\n\n\u003c!-- badges: start --\u003e\n[![polarssql status badge](https://rpolars.r-universe.dev/badges/polarssql)](https://rpolars.r-universe.dev)\n[![CRAN status](https://www.r-pkg.org/badges/version/polarssql)](https://CRAN.R-project.org/package=polarssql)\n\u003c!-- badges: end --\u003e\n\n`{polarssql}` is an experimental DBI-compliant interface to [Polars](https://www.pola.rs/).\n\nPolars is not an actual database, so does not support full `{DBI}` functionality.\nPlease check [the Polars User Guide](https://pola-rs.github.io/polars/user-guide/sql/intro/)\nfor supported SQL features.\n\n## Installation\n\nThe `{polars0}` R package and `{polarssql}`\ncan be installed from [R-universe](https://rpolars.r-universe.dev/):\n\n```r\nSys.setenv(NOT_CRAN = \"true\") # for installing the polars package with pre-built binary\ninstall.packages(\"polarssql\", repos = c(\"https://rpolars.r-universe.dev\", getOption(\"repos\")))\n```\n\n## Example\n\n```{r}\nlibrary(DBI)\n\ncon \u003c- dbConnect(polarssql::polarssql())\ndbWriteTable(con, \"mtcars\", mtcars)\n\n# We can fetch all results:\nres \u003c- dbSendQuery(con, \"SELECT * FROM mtcars WHERE cyl = 4\")\ndbFetch(res)\n\n# Clear the result\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\n# Clear the result\ndbClearResult(res)\n\n# We can use table functions to read files directly:\ntf \u003c- tempfile(fileext = \".parquet\")\non.exit(unlink(tf))\npolars0::as_polars_lf(mtcars)$sink_parquet(tf)\n\ndbGetQuery(con, paste0(\"SELECT * FROM read_parquet('\", tf, \"') ORDER BY mpg DESC LIMIT 3\"))\n```\n\n`{polarssql}` also provides functions that are simpler to use, inspired by the `{duckdb}` package,\n\n```{r}\nlibrary(polarssql)\n\n# These functions use the built-in connection by default, so we don't need to specify connection\n\n# Resgister a data.frame to the built-in connection\npolarssql_register(df = mtcars)\n\n# Get the query result as a polars LazyFrame\npolarssql_query(\"SELECT * FROM df WHERE cyl = 4\")\n\n# Unregister the table\npolarssql_unregister(\"df\")\n```\n\nAnd, basic supports for `{dbplyr}` is also implemented.\n\n```{r}\nlibrary(dplyr, warn.conflicts = FALSE)\n\n# Resgister a data.frame to the built-in connection, and query it via dbplyr\ntbl_polarssql(mtcars) |\u003e\n  filter(cyl == 4) |\u003e\n  arrange(desc(mpg)) |\u003e\n  head(3) |\u003e\n  compute()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpolars%2Fr-polarssql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frpolars%2Fr-polarssql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frpolars%2Fr-polarssql/lists"}