Learn R Programming

SQRL (version 0.7.4)

SQRL-package: Facilitates Database Interaction

Description

Streamlines exploratory work and short-order ad hoc jobs on ODBC data sources.

Arguments

Details

Automatically generates a dedicated and like-named interface function to each ODBC DSN (Open DataBase Connectivity Data Source Name). These functions manage communications behind the scenes, whilst supporting multi-statement SQL scripts. Hybrid (SQRL) scripting syntax allows SQL with embedded R, thereby enabling parameterisation of queries, feedback of intermediate results, the addition of flow-control structures within and around SQL, and the use of libraries of stored scripts. Additional sources and interfaces can be defined at any time. The package is a wrapper about RODBC. This is version 0.7.4.

See Also

sqrlSources, sqrlUsage

Examples

Run this code
# NOT RUN {
require(SQRL)

# Show (automatic) data sources.
sqrlSources()

# }
# NOT RUN {
# If 'ratatoskr' were one of those sources (i.e.,
# if a DSN of that name was found), then a multi-
# statement query could be submitted like so:
ratatoskr("use yggdrasil; select messages from ",
          "vedfolnir where addressee = 'nidhogg' ",
          "limit ", 5)

# Submit a parameterised query from file.
ratatoskr("messages.sqrl", year = 950)

# Obtain help on usage.
ratatoskr("help")
# }
# NOT RUN {
# Define a new data source (interface).
sqrlSource("mysource",
           driver = "MYSQL ODBC 5.3 ANSI Driver",
           server = "localhost",
           user = "<uid>",
           password = "<pwd>")

# }
# NOT RUN {
# Submit a query to the new source.
mysource("select * from database.table")
# }

Run the code above in your browser using DataLab