RODBC in execute R works in RM but not work in web service
juju
New Altair Community Member
Hi I'm doing read/write database in execute R. I'm using RODBC library in R for it.
This works in RM studio,
but when I make it a web service, it has error
de.rapidanalytics.ejb.service.ServiceDataSourceException: Error executing process
/home/RM/test_db_connection_in_web_service for service test_db_connection_in_web_service: The execution of the R script failed.
Here's the code (if you want to test, you need to change the server name, the database name and the table name.)
Any help's appreciated. Thank you!
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="6.4.000">
<context>
<input/>
<output/>
<macros/>
</context>
<operator activated="true" class="process" compatibility="6.4.000" expanded="true" name="Process">
<process expanded="true">
<operator activated="true" class="read_database" compatibility="6.4.000" expanded="true" height="60" name="Read Database" width="90" x="313" y="30">
<parameter key="connection" value="AnalyticsEngine"/>
<parameter key="define_query" value="table name"/>
<parameter key="table_name" value="table1"/>
<enumeration key="parameters"/>
</operator>
<operator activated="false" class="r_scripting:execute_r" compatibility="6.4.000" expanded="true" height="60" name="Execute R" width="90" x="313" y="120">
<parameter key="script" value="library(RODBC) rm_main = function(){ ch = odbcDriverConnect("Driver={SQL Server};Server=sao-dev-db22;Database=AnalyticsEngine;Trusted_Connection=True") rule_dtype_matching = sqlFetch(ch, 'mini_meta_rule_dtype_matching') odbcClose(ch) rule_dtype_matching } "/>
</operator>
<operator activated="true" class="r_scripting:execute_r" compatibility="6.4.000" expanded="true" height="76" name="Execute R (2)" width="90" x="313" y="210">
<parameter key="script" value="library(RODBC) rm_main = function(){ ch = odbcDriverConnect("Driver={SQL Server};Server=db22;Database=AnalyticsEngine;Trusted_Connection=True") sql0 = sprintf("SELECT * FROM [dbo].[table1]") dat = sqlQuery(ch, sql0) dat } "/>
</operator>
<connect from_op="Read Database" from_port="output" to_port="result 1"/>
<connect from_op="Execute R (2)" from_port="output 1" to_port="result 2"/>
<portSpacing port="source_input 1" spacing="0"/>
<portSpacing port="sink_result 1" spacing="0"/>
<portSpacing port="sink_result 2" spacing="0"/>
<portSpacing port="sink_result 3" spacing="0"/>
</process>
</operator>
</process>
0
Answers
-
You can not create a Web Service in RapidMiner Studio, you need to use RapidMiner Server.
0