Package 'connections'

Title: Integrates with the 'RStudio' Connections Pane and 'pins'
Description: Enables 'DBI' compliant packages to integrate with the 'RStudio' connections pane, and the 'pins' package. It automates the display of schemata, tables, views, as well as the preview of the table's top 1000 records.
Authors: Edgar Ruiz [aut, cre], Posit Software, PBC [cph, fnd]
Maintainer: Edgar Ruiz <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2024-09-14 04:07:44 UTC
Source: https://github.com/rstudio/connections

Help Index


Close a connection

Description

Close a connection

Usage

connection_close(con, host = "", type = "", leave_open = FALSE)

Arguments

con

Connection variable

host

Host name of the connection. Optional, defaults to empty

type

Type of connection. Optional, defaults to empty

leave_open

Should the connection be left open. Defaults to FALSE

Value

Returns a NULL object. If using the RStudio IDE, it will attempt to close the connection identified by the 'host' and 'type' arguments, or the con object

Examples

library(DBI)
con <- connection_open(RSQLite::SQLite(), path = ":dbname:")
connection_close(con)
con

Displays the code that will be used to recreate the connection

Description

Displays the code that will be used to recreate the connection

Usage

connection_code(con)

Arguments

con

A 'connConnection' object

Value

It prints out the lines of code that this package will use to reconnect to the database.


Opens a connection

Description

Opens a connection

Usage

connection_open(..., open_pane = TRUE)

Arguments

...

Passes arguments to wrapped connection function

open_pane

Signals for the RStudio Connections pane to open. Defaults to TRUE.

Value

Returns a NULL object. If using the RStudio IDE, it will attempt to open the connection

Examples

library(DBI)
con <- connection_open(RSQLite::SQLite(), path = ":dbname:")
con
connection_close(con)

Retrieves a database connection or query from a board

Description

Retrieves a database connection or query from a board

Usage

connection_pin_read(board, name, version = NULL)

Arguments

board

A 'pins' board object

name

The name of the pin

version

The version of the pin to get (optional)

Value

It will return either the database connection, or the remote table from a database.


Writes a database connection or query to a board

Description

Writes a database connection or query to a board

Usage

connection_pin_write(board, x, ...)

Arguments

board

A 'pins' board object

x

A 'connections' table or database connection

...

Additional arguments to pass to 'pins::pin_write()'

Value

It returns no output.


Refreshes a connection

Description

Refreshes a connection

Usage

connection_update(con, hint = "")

Arguments

con

Connection variable

hint

Optional argument passed to the Contract

Value

Returns a NULL object. If using the RStudio IDE, it will attempt to refresh the connection identified by attributes of the con object

Examples

library(DBI)
con <- connection_open(RSQLite::SQLite(), path = ":dbname:")
connection_update(con)
connection_close(con)

Populates the RStudio Connection viewer

Description

Populates the RStudio Connection viewer

Usage

connection_view(
  con,
  connection_code = "",
  host = "",
  name = "",
  connection_id = ""
)

Arguments

con

Connection variable

connection_code

Text of code to connect to the same source

host

Name of Host of the connection

name

Connection name

connection_id

Unique ID of the connection for the current session

Value

It populates the RStudio Connections pane. It returns nothing to the console or session.

Examples

library(DBI)
con <- connection_open(RSQLite::SQLite(), path = ":dbname:")
connection_view(con)
connection_close(con)