{"id":13857764,"url":"https://github.com/poissonconsulting/readwritesqlite","last_synced_at":"2025-04-09T20:13:35.617Z","repository":{"id":34863301,"uuid":"158617726","full_name":"poissonconsulting/readwritesqlite","owner":"poissonconsulting","description":"An R package that enhances writing and reading data to and from SQLite databases","archived":false,"fork":false,"pushed_at":"2025-01-14T21:09:43.000Z","size":2774,"stargazers_count":37,"open_issues_count":9,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-09T20:13:29.674Z","etag":null,"topics":["cran","dbi","log","metadata","posixct","r","read","rstats","sfc","sqlite","units","write"],"latest_commit_sha":null,"homepage":"https://poissonconsulting.github.io/readwritesqlite/","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/poissonconsulting.png","metadata":{"files":{"readme":"README.Rmd","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":null,"support":".github/SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-21T23:26:36.000Z","updated_at":"2025-03-22T11:01:11.000Z","dependencies_parsed_at":"2024-09-17T21:26:56.692Z","dependency_job_id":"cfdae669-e61a-4ad0-b225-44567d0eefdd","html_url":"https://github.com/poissonconsulting/readwritesqlite","commit_stats":{"total_commits":312,"total_committers":6,"mean_commits":52.0,"dds":"0.10256410256410253","last_synced_commit":"db961138ad98b957b70b3e4f257ab8c9c317b8e2"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poissonconsulting%2Freadwritesqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poissonconsulting%2Freadwritesqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poissonconsulting%2Freadwritesqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poissonconsulting%2Freadwritesqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poissonconsulting","download_url":"https://codeload.github.com/poissonconsulting/readwritesqlite/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"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":["cran","dbi","log","metadata","posixct","r","read","rstats","sfc","sqlite","units","write"],"created_at":"2024-08-05T03:01:46.289Z","updated_at":"2025-04-09T20:13:35.589Z","avatar_url":"https://github.com/poissonconsulting.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n# readwritesqlite \u003cimg src=\"man/figures/logo.png\" style=\"float: right\" /\u003e\n\u003c!-- badges: start --\u003e\n[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)\n[![R-CMD-check](https://github.com/poissonconsulting/readwritesqlite/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/poissonconsulting/readwritesqlite/actions/workflows/R-CMD-check.yaml)\n[![Codecov test coverage](https://codecov.io/gh/poissonconsulting/readwritesqlite/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/readwritesqlite)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/license/mit/)\n[![CRAN status](https://www.r-pkg.org/badges/version/readwritesqlite)](https://cran.r-project.org/package=readwritesqlite)\n![CRAN Downloads](http://cranlogs.r-pkg.org/badges/readwritesqlite)\n\u003c!-- badges: end --\u003e\n\n# readwritesqlite\n\nSQLite databases are a simple, powerful way to validate, query and store related data frames particularly when used with the RSQLite package.\nHowever, current solutions do not preserve (or check) meta data, log changes or provide particularly useful error messages.\n\n`readwritesqlite` is an R package that by default\n\n- preserves (and subsequently checks) the following metadata\n  - the class for logical, Date and hms columns\n  - the levels for factors and ordered factors\n  - the time zone for POSIXct columns\n  - the units for unit columns\n  - the projection for sfc columns\n  - the sf column for sf objects\n- logs \n    - the date time\n    - system user\n    - table creation and data insertion or deletion\n- provides informative error messages if\n    - columns are missing\n    - NOT NULL columns contain missing values\n    - PRIMARY KEY column values in the input data are not unique\n    \n`readwritesqlite` also allows the user to \n\n- write environments (or named lists) of data frames (useful for populating databases)\n- delete existing data (and meta data) before writing (useful for converting an existing database)\n- replace existing data which causes unique or primary key conflicts (useful for updating databases)\n- confirm data can be written without committing any changes (useful for checking data)\n- check all existing tables are written to (useful for data transfers)\n- rearrange and add levels for factors and add levels for ordered factors\n- initialize the meta data for a new table by writing a data frame or sf data frame with no rows but logical, Date, factor, ordered, POSIXct, sfc or unit columns (useful for creating an empty database with additional informative checks)\n\n`readwritesqlite` provides all these features through its `rws_write()` and `rws_read()` functions.\n\nThe `rws_query()` function allows the user to pass a SQL query.\nBy default, the metadata (except the setting of the sf column) is, if unambiguously defined, preserved for each column in the final query.\nTo enable this functionality the user should ensure that a) columns in tables which will be referenced in the same query should have different names or identical metadata and b) column names in the final query should match those in the referenced base tables.\n\nThe init, meta and log data are stored in separate tables from the main data which means that they do not interfere with other ways of interacting with a SQLite database.\n\n## Installation\n\nTo install the latest release from [CRAN](https://cran.r-project.org)\n```r\ninstall.packages(\"readwritesqlite\")\n```\n\nTo install the developmental version from [GitHub](https://github.com/poissonconsulting/readwritesqlite)\n```r\n# install.packages(\"remotes\")\nremotes::install_github(\"poissonconsulting/readwritesqlite\")\n```\n\n## Demonstration\n\nKey attribute information is preserved for many classes.\n```{r}\nlibrary(readwritesqlite)\n\n# for nicer printing of data frames\nlibrary(tibble)\nlibrary(sf)\n\nconn \u003c- rws_connect()\n\nrws_data \u003c- readwritesqlite::rws_data\nrws_data\n\nrws_write(rws_data, exists = FALSE, conn = conn)\n\nrws_read_table(\"rws_data\", conn = conn)\n```\n\nThe attribute information is stored in the metadata table\n```{r}\nrws_read_meta(conn = conn)\n```\n\nThe user can add descriptions if they wish.\n```{r}\nrws_describe_meta(\"rws_data\", \"posixct\", \"The time of a visit\", conn = conn)\nrws_describe_meta(\"rws_data\", \"units\", \"The site length.\", conn = conn)\nrws_read_meta(conn = conn)\n```\n\nThe log provides a record of data changes that have been made using readwritesqlite.\n``` r\nrws_read_log(conn = conn)\n#\u003e # A tibble: 2 x 5\n#\u003e   DateTimeUTCLog      UserLog TableLog CommandLog NRowLog\n#\u003e   \u003cdttm\u003e              \u003cchr\u003e   \u003cchr\u003e    \u003cchr\u003e        \u003cint\u003e\n#\u003e 1 2019-07-07 16:05:10 joe     RWS_DATA CREATE           0\n#\u003e 2 2019-07-07 16:05:11 joe     RWS_DATA INSERT           3\n```\n\nDon't forget to disconnect when done.\n```{r}\nrws_disconnect(conn)\n```\n\n## Information\n\nFor more information on using `readwritesqlite` see the vignette [using-readwritesqlite](https://poissonconsulting.github.io/readwritesqlite/articles/using-readwritesqlite.html).\n\n## Contribution\n\nPlease report any [issues](https://github.com/poissonconsulting/readwritesqlite/issues).\n\n[Pull requests](https://github.com/poissonconsulting/readwritesqlite/pulls) are always welcome.\n\n## Code of Conduct\n\nPlease note that the readwritesqlite project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/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%2Fpoissonconsulting%2Freadwritesqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoissonconsulting%2Freadwritesqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoissonconsulting%2Freadwritesqlite/lists"}