我想使用RxSqlServerData
运行以下连接字符串和查询:
connString <- paste("Driver=SQL Server", paste("Server=", config$dwServer, sep = ""), paste("Database=", config$dwName, sep = ""), "trusted_connection=true", sep = ";")
rxSetComputeContext("local")
query <- "SELECT * FROM Table1"
RxSqlServerData(sqlQuery=query,connectionString=connString)
我指定可信连接/窗口身份验证的语法似乎是错误的。任何人都可以告诉我如何使用RevoScaleR
包正确使用可信连接吗?
答案 0 :(得分:1)
这是我如何让我的工作。请注意,您必须在ODBC数据源管理器中设置ODBC DSN,然后您需要确保连接字符串中的驱动程序名称与DSN正在使用的名称相匹配。就我而言,它是&#34; SQL Server Native Client 11.0&#34;。大括号似乎允许驱动程序名称中的空格。另外,我必须将trusted_connection
参数设置为&#34;是&#34;而不是&#34; true&#34;。
instance_name <- "yourDsnName";
database_name <- "youDataBaseName";
connStr <- paste("Driver={SQL Server Native Client 11.0};Server=",instance_name, ";Database=",database_name,";Trusted_Connection=yes;",sep="");
# Set other variables used to define the compute context
sqlWait = TRUE;
sqlConsoleOutput = FALSE;
sqlShareDir <- paste("C:\\RShared\\",Sys.getenv("USERNAME"),sep="")
# Create and set the compute context to Dev SQL Server
sqlCC <- RxInSqlServer(connectionString = connStr, shareDir = sqlShareDir,
wait = sqlWait, consoleOutput = sqlConsoleOutput,
traceEnabled=TRUE,traceLevel=7)
rxSetComputeContext(sqlCC)
rxGetVarInfo(RxSqlServerData(sqlQuery = "select 1 as test",connectionString = connStr, colClasses = c(test = "integer"), rowsPerRead=500))