首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SQL R服务(jsonlite、curl)

SQL R服务(jsonlite、curl)
EN

Stack Overflow用户
提问于 2016-11-03 22:25:13
回答 1查看 647关注 0票数 1

概述

我想使用SQL R Services调用API并将数据直接提取到SQL Server中。我一直在尝试在R中使用jsonlite和curl,在R GUI中使用成功,但在通过SQL Server T-SQL进行调用时失败。

R脚本

代码语言:javascript
复制
library(jsonlite,curl);
citibike <- fromJSON('http://citibikenyc.com/stations/json');
stations <- citibike$stationBeanList;
stations[,c(2,10)];

SQL脚本

代码语言:javascript
复制
DECLARE @Rscript NVARCHAR(MAX);
SET @Rscript = N'library(jsonlite, curl);
    citibike <- fromJSON('+''''+'http://citibikenyc.com/stations/json'+''''+');
     stations <- citibike$stationBeanList;
     OutputDataSet <- subset(stations, select=c("stationName", "stAddress1"))';
EXEC sp_execute_external_script
     @language = N'R',
     @script = @Rscript
    WITH RESULT SETS(([stationName] VARCHAR(500), [stAddress1] VARCHAR(500)));

SQL错误

代码语言:javascript
复制
Msg 39004, Level 16, State 20, Line 0
A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 1, Line 0
An external script error occurred: 
Error in open.connection(con, "rb") : Couldn't connect to server
Calls: source ... fromJSON_string -> parseJSON -> parse_con -> open -> open.connection
In addition: Warning message:
package 'jsonlite' was built under R version 3.3.2 

Error in ScaleR.  Check the output for more information.
Error in eval(expr, envir, enclos) : 
  Error in ScaleR.  Check the output for more information.
Calls: source -> withVisible -> eval -> eval -> .Call
Execution halted
Msg 11536, Level 16, State 1, Line 8
EXECUTE statement failed because its WITH RESULT SETS clause specified 1 result set(s), but the statement only sent 0 result set(s) at run time.

问题

有没有我应该考虑的另一种方法,或者是否有一些简单的错误正在阻止它在SQL R Services中工作?

EN

回答 1

Stack Overflow用户

发布于 2016-11-04 19:17:58

问题原来是一个防火墙规则,它只影响SQL R服务,但不影响在同一台计算机上通过R GUI或R CLI运行相同的脚本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40404037

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档