Skip to content

Commit f4867c2

Browse files
committed
Documents new function, version bump, changes license to MIT, moving around functions, makes Edgar the maintainer, adds Posit to Authors, passes checks
1 parent 4cf043e commit f4867c2

10 files changed

+155
-90
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ local.sqlite
88
data.rds
99
^cran-comments\.md$
1010
^CRAN-RELEASE$
11+
^LICENSE\.md$

DESCRIPTION

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
Package: connections
22
Title: Integrates with the 'RStudio' Connections Pane and 'pins'
3-
Version: 0.1.2
3+
Version: 0.1.2.9000
44
Authors@R:
55
c(
6-
person("Nathan", "Stephens", email = "nathan@rstudio.com", role = c("aut", "cre")),
7-
person("Edgar", "Ruiz", email = "[email protected]", role = c("aut"))
6+
person("Edgar", "Ruiz", email = "edgar@posit.com", role = c("aut", "cre")),
7+
person(given = "Posit Software, PBC", role = c("cph", "fnd"))
88
)
99
Description: Enables 'DBI' compliant packages to integrate with the 'RStudio' connections
1010
pane, and the 'pins' package. It automates the display of schemata, tables, views, as well
1111
as the preview of the table's top 1000 records.
12-
License: GPL-3
12+
License: MIT + file LICENSE
1313
Imports:
1414
DBI,
1515
methods,

LICENSE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
YEAR: 2023
2+
COPYRIGHT HOLDER: connections authors

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# MIT License
2+
3+
Copyright (c) 2023 connections authors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

R/connection-pin-read.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#' Retrieves a database connection or query from a board
2+
#' @param board A `pins` board object
3+
#' @param name The name of the pin
4+
#' @param version The version of the pin to get (optional)
5+
#' @export
6+
connection_pin_read <- function(board, name, version = NULL) {
7+
pinned <- pin_read(board = board, name = name, version = version)
8+
read_pin_conn(pinned)
9+
}
10+
11+
read_pin_conn <- function(x) {
12+
UseMethod("read_pin_conn")
13+
}
14+
15+
read_pin_conn.conn_open <- function(x) {
16+
dbi_conn <- dbi_run_code(x)
17+
connection_view(dbi_conn)
18+
dbi_conn
19+
}
20+
21+
read_pin_conn.conn_table <- function(x) {
22+
con <- dbi_run_code(x$con)
23+
tbl_read <- x$tbl
24+
tbl_read$src$con <- con@con
25+
init_dbplyr <- dbplyr::remote_src(tbl_read)
26+
tbl_read
27+
}

R/connection-pin-write.R

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#' Writes a database connection or query to a board
2+
#' @param board A `pins` board object
3+
#' @param x A `connections` table or database connection
4+
#' @param ... Additional arguments to pass to `pins::pin_write()`
5+
#' @export
6+
connection_pin_write <- function(board, x, ...) {
7+
write_pin_conn(
8+
x = x,
9+
board = board,
10+
...
11+
)
12+
}
13+
14+
write_pin_conn <- function(x, board, ...) {
15+
UseMethod("write_pin_conn")
16+
}
17+
18+
write_pin_conn.connConnection <- function(x, board, ...) {
19+
session <- conn_session_get(x@id)
20+
metadata <- list(
21+
host = session$host,
22+
type = session$type
23+
)
24+
x <- structure(session, class = "conn_open")
25+
pin_write(
26+
x = x,
27+
board = board,
28+
type = "rds",
29+
metadata = metadata,
30+
...
31+
)
32+
invisible()
33+
}
34+
35+
write_pin_conn.tbl_conn <- function(x, board, ...) {
36+
session <- conn_session_get(attr(x, "conn_id"))
37+
con <- structure(session, class = "conn_open")
38+
39+
metadata <- list(
40+
host = con$host,
41+
type = con$type,
42+
columns = lapply(collect(head(x, 10)), class)
43+
)
44+
45+
pin_obj <- structure(
46+
list(
47+
con = con,
48+
tbl = x
49+
),
50+
class = "conn_table"
51+
)
52+
53+
pin_write(
54+
x = pin_obj,
55+
board = board,
56+
type = "rds",
57+
metadata = metadata,
58+
...
59+
)
60+
invisible()
61+
}
62+
63+
64+

R/pins-connection.R

Lines changed: 0 additions & 49 deletions
This file was deleted.

R/pins-table.R

Lines changed: 0 additions & 37 deletions
This file was deleted.

man/connection_pin_read.Rd

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/connection_pin_write.Rd

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)