-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
96 lines (67 loc) · 2.99 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# dbflobr <img src="man/figures/logo.png" align="right" />
<!-- badges: start -->
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![R-CMD-check](https://github.com/poissonconsulting/dbflobr/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/poissonconsulting/dbflobr/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/poissonconsulting/dbflobr/graph/badge.svg)](https://app.codecov.io/gh/poissonconsulting/dbflobr)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![CRAN status](https://www.r-pkg.org/badges/version/dbflobr)](https://cran.r-project.org/package=dbflobr)
![CRAN downloads](https://cranlogs.r-pkg.org/badges/dbflobr)
<!-- badges: end -->
`dbflobr` reads and writes files to SQLite databases as [flobs](https://github.com/poissonconsulting/flobr).
A flob is a [blob](https://github.com/tidyverse/blob) that preserves the file extension.
## Installation
To install the latest release from [CRAN](https://cran.r-project.org)
```r
install.packages("dbflobr")
```
To install the developmental version from [GitHub](https://github.com/poissonconsulting/dbflobr)
```r
# install.packages("remotes")
remotes::install_github("poissonconsulting/dbflobr")
```
## Demonstration
```{r}
library(dbflobr)
# convert a file to flob using flobr
flob <- flobr::flob(system.file("extdata", "flobr.pdf", package = "flobr"))
str(flob)
# create a SQLite database connection
conn <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
# create a table 'Table1' of data
DBI::dbWriteTable(conn, "Table1", data.frame(IntColumn = c(1L, 2L)))
DBI::dbReadTable(conn, "Table1")
# specify which row to add the flob to by providing a key
key <- data.frame(IntColumn = 2L)
# write the flob to the database in column 'BlobColumn'
write_flob(flob, "BlobColumn", "Table1", key, conn, exists = FALSE)
DBI::dbReadTable(conn, "Table1")
# read the flob
flob2 <- read_flob("BlobColumn", "Table1", key, conn)
str(flob2)
# delete the flob
delete_flob("BlobColumn", "Table1", key, conn)
DBI::dbReadTable(conn, "Table1")
# close the connection
DBI::dbDisconnect(conn)
```
## Inspiration
- [blob](https://github.com/tidyverse/blob)
- [flobr](https://github.com/poissonconsulting/flobr)
## Contribution
Please report any [issues](https://github.com/poissonconsulting/dbflobr/issues).
[Pull requests](https://github.com/poissonconsulting/dbflobr/pulls) are always welcome.
## Code of Conduct
Please note that the dbflobr project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html).
By contributing to this project, you agree to abide by its terms