RSQLServer (version 0.2.0)

SQLServer: Create a SQLServer driver

Description

This creates a SQL Server driver used to access SQL Server databases and is based on the jTDS driver.

Connect to/disconnect from a SQL Server database.

Usage

SQLServer(identifier.quote = "\"")
"dbConnect"(drv, server, file = NULL, database = "", type = "sqlserver", port = "", properties = list())

Arguments

identifier.quote
quote character for a SQL Server identifier can be a double quotation mark (\") which is the default.
drv
An objected of class SQLServerDriver, or an existing SQLServerConnection. If a connection, the connection will be cloned.
server
the server address or recognised alias thereof.
file
defaults to using the server details file in $HOME/sql.yaml. The server details including type, port and any optional properties can be sourced from this file. If the server name is found in file, the details therein are used (and in particular, those provided in other arguments to this function are ignored). The connection method prefers server details to be provided in a "sql.yaml" file rather than provided as arguments to this function. If you wish to specify the details as parameters, ensure that either the file does not exist or that the server details are not in the YAML file.
database
the name of the database hosted on the server. If an empty string, a connection to the default database on server is assumed.
type
the server type. Must be either "sqlserver" or "sybase". Defaults to "sqlserver".
port
the TCP/IP default port. This will be coerced to a string. Defaults to 1433 if an empty string (jTDS behaviour).
properties
One or more optional connection properties. in a named list. Note if you intend to set the useNTLMv2 property to 'true' from the default API value of 'false', you will need to make a specific authentication driver available to the SQL Server driver, although this hasn't worked particularly well in testing. See RSQLServer for more details. Should you wish to use Windows authentication to connect to the server, I recommend you set the following optional parameters: set useNTLMv2 to 'true', domain to your domain and user and password to your username and password on domain. jTDS' SSO functionality is flaky.

Value

An object of class SQLServerDriver.a SQLServerConnection

References

jTDS project

Examples

Run this code
## Not run: 
# SQLServer()
# ## End(Not run)
# View sql.yaml file bundled in package
file <- system.file("extdata", "sql.yaml", package = "RSQLServer")
readLines(file)
# Connect using ~/sql.yaml file
## Not run: 
# if (have_test_server()) {
#  dbConnect(RSQLServer::SQLServer(), "TEST")
# }
# # Example where ~/sql.yaml does not exist or where the server
# # is not in the YAML file.
# dbConnect(RSQLServer::SQLServer(), server="11.1.111.11", port=1434,
#    properties=list(useNTLMv2="true", domain="myco", user="me",
#      password="asecret"))
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace