Learn R Programming

SQRL (version 0.5.0)

sqrlSource: Define New Data Sources

Description

Defines new data sources and creates the interface functions for communicating with them. Can also redefine and/or delete existing sources.

Usage

sqrlSource(...)

Arguments

A name and definition for the source (refer to the details section, below).

Value

for Returns invisible NULL, after creating an interface to the newly defined source.

Details

The arguments may be specified as a single name = definition pair. In this usage, definition may be a connection string, a configuration file, a data source name (DSN), or the name of an existing SQRL source. In the case of a configuration file, the new source (name) is defined by importing all the parameter settings of that file (see sqrlConfig). In the case of an existing SQRL source, the new source is defined as a copy of the original.

Alternatively, the arguments may be supplied as a list of strings. In this usage, the first string is taken for the new source name while the remainder comprise the definition (connection strings and file paths may be provided as components).

Lastly, the arguments may instead be supplied as a single string followed by at least one parameter = value pair. In this usage, the string is taken for the new source name, and the pairs as components of the defining connection string (or DSN).

Whichever form is used, the new source name must not conflict with that of any other object on the R search path (or else an error will be thrown), unless the source is being defined from a configuration file that defines an interface name (in which case, that name may not conflict with any object already on the search path). Redefinition of an existing source is allowed, provided it is closed.

When the name is ‘remove’, the definition is interpreted as a list of sources to be deregistered. This precludes the use of ‘remove’ as a source name.

See Also

sqrlConfig, sqrlParams, RODBC:odbcConnect

Examples

Run this code
# NOT RUN {
# Define a new source from a DSN.
sqrlSource("daedalus", dsn = "Knossos")

# Define another source as a copy of the former.
sqrlSource(icarus = "daedalus")

# Redefine an existing source by a connection string.
# (This example is for a Windows-system client.)
sqrlSource("icarus",
            driver = "PostgreSQL ANSI(x64)",
            server = "localhost",
            port = 5432,
            uid = "asterion",
            pwd = "moo")

# Define a new source by a connection string.
# (This example is for a GNU/Linux-system client,
#  and employs the <pwd> password placeholder.)
sqrlSource("knossos",
            "dbcname=Knossos;uid=theseus;pwd=<pwd>",
            "driver=/opt/teradata/client/16.10/lib64/tdata.so")

# }
# NOT RUN {
# Define a new source from a configuration file.
sqrlSource(minos = "path/to/minos.config")

# Source names may conflict with those of preexisting
# R objects, provided that the config file defines a 
# conflict-free name for the source's interface function.
sqrlSource("c", "path/to/", "c.config")
# }
# NOT RUN {
# Review defined sources.
sqrlSources()

# Remove two of the sources.
sqrlSource("remove", c("daedalus", "knossos")) 
# }

Run the code above in your browser using DataLab