1

我有以下连接字符串和要运行的查询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包的可信连接?

4

1 回答 1

2

这就是我如何让我的工作。请注意,您必须在 ODBC 数据源管理器中设置 ODBC DSN,然后您需要确保连接字符串中的驱动程序名称与您的 DSN 使用的完全匹配。就我而言,它是“SQL Server Native Client 11.0”。花括号似乎允许在驱动程序名称中使用空格。另外,我必须将trusted_connection参数设置为“yes”而不是“true”。

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))
于 2016-08-19T22:03:00.223 回答