Title: | Generic implementation of the 'RStudio' connections contract |
---|---|
Description: | Provides a generic implementation of the 'RStudio' connection contract to make it easier for database connections, and other type of connections, opened via R packages integrate with the connections pane inside the 'RStudio' interactive development environment (IDE). |
Authors: | Nathan Stephens [aut, cre], Edgar Ruiz [aut] |
Maintainer: | Nathan Stephens <[email protected]> |
License: | GPL-3 |
Version: | 0.1.2 |
Built: | 2024-11-09 05:38:26 UTC |
Source: | https://github.com/rstudio/rscontract |
Coerces object into an RStudio connection contract
as_rscontract(x)
as_rscontract(x)
x |
Object that will be coerced |
An 'rs_contract_ide' class object
as_rscontract(sample_catalog())
as_rscontract(sample_catalog())
Close a connection
rscontract_close(host = "", type = "")
rscontract_close(host = "", type = "")
host |
Host name of the connection. Optional, defaults to empty |
type |
Type of connection. Optional, defaults to empty |
Returns a NULL object. If using the RStudio IDE, it will attempt to close the connection identified by the 'host' and 'type' arguments
rscontract_open(rscontract_spec()) rscontract_close("spec_host", "spec_type")
rscontract_open(rscontract_spec()) rscontract_close("spec_host", "spec_type")
Creates an object that contains all of the necessary information to create a connection contract. This function if meant as a lower level integration with the connections pane.
rscontract_ide( connectionObject = NULL, type = "", host = "", icon = NULL, displayName = "", connectCode = "", disconnect = function() { }, previewObject = function() { }, listObjectTypes = default_types(), listObjects = function() { }, listColumns = function() { }, actions = NULL )
rscontract_ide( connectionObject = NULL, type = "", host = "", icon = NULL, displayName = "", connectCode = "", disconnect = function() { }, previewObject = function() { }, listObjectTypes = default_types(), listObjects = function() { }, listColumns = function() { }, actions = NULL )
connectionObject |
The connection object. Default to NULL. |
type |
Type of the connection. |
host |
Name of the host |
icon |
Path to the connection's icon. Defaults to NULL. |
displayName |
The connection's name. |
connectCode |
The text of the connection code. |
disconnect |
Function to use to disconnect. Default to function(). |
previewObject |
Function to run when the preview table icon is clicked on. Default to function(). |
listObjectTypes |
Function that provides the structure of the connection. The default function will work properly, it is going to be rare when it needs to be changed. |
listObjects |
Function to run to get the catalogs, schema, tables or views based what has been expanded on. Default to function(). |
listColumns |
Function to run that pull the field information. Default to function(). |
actions |
Additional buttons to add to the connection pane. Defaults to NULL. |
An 'rs_contract_ide' class object
str(rscontract_ide())
str(rscontract_ide())
Opens a connection
rscontract_open(x)
rscontract_open(x)
x |
An rscontract_ide object, or an object coercible to an rscontract_ide |
Returns a NULL object. If using the RStudio IDE, it will attempt to open the connection, and set the identification using the 'host' and 'type' argument values
rscontract_open(rscontract_spec()) rscontract_close("spec_host", "spec_type")
rscontract_open(rscontract_spec()) rscontract_close("spec_host", "spec_type")
A flexible API that can be converted to an RStudio Connection Contract
rscontract_spec( connection_object = NULL, type = "spec_type", host = "spec_host", icon = NULL, name = "", connect_script = "library(connections)\n[Place your code here]", disconnect_code = "function() rscontract_close('spec_host', 'spec_type')", preview_code = "function(){}", catalog_list = "sample_catalog()", object_types = "default_types()", object_list = NULL, object_columns = NULL, actions = NULL )
rscontract_spec( connection_object = NULL, type = "spec_type", host = "spec_host", icon = NULL, name = "", connect_script = "library(connections)\n[Place your code here]", disconnect_code = "function() rscontract_close('spec_host', 'spec_type')", preview_code = "function(){}", catalog_list = "sample_catalog()", object_types = "default_types()", object_list = NULL, object_columns = NULL, actions = NULL )
connection_object |
The connection object. Default to NULL. |
type |
Type of the connection. |
host |
Name of the host |
icon |
Path to the connection's icon. Defaults to NULL. |
name |
The connection's name. |
connect_script |
The text of the connection code. |
disconnect_code |
Function to use to disconnect. Default to function(). |
preview_code |
Function to run when the preview table icon is clicked on. Default to function(). |
catalog_list |
Hierarchical list of the catalogs, schema, table/view and fields. |
object_types |
Function that provides the structure of the connection. The default function will work properly, it is going to be rare when it needs to be changed. |
object_list |
Function to run to get the catalogs, schema, tables or views based what has been expanded on. Defaults to NULL. |
object_columns |
Function to run that pull the field information. Default to NULL |
actions |
Additional buttons to add to the connection pane. Defaults to NULL. |
Returns an 'rscontract_spec' class object
str(rscontract_spec())
str(rscontract_spec())
Refreshes a connection
rscontract_update(host = "", type = "", hint = "")
rscontract_update(host = "", type = "", hint = "")
host |
Connection's Host name |
type |
The connection's type |
hint |
Optional argument passed to the Contract |
Returns a NULL object. If using the RStudio IDE, it will attempt to refresh the connection identified by the 'host' and 'type' arguments
con <- rscontract_open(rscontract_spec()) rscontract_update(con) rscontract_close(con)
con <- rscontract_open(rscontract_spec()) rscontract_update(con) rscontract_close(con)
A example of how a connection hierarchy structure
sample_catalog()
sample_catalog()
A 'list' object containing all of the needed information to open a very simple connection contract
str(sample_catalog())
str(sample_catalog())