Forum Discussion
RScript Error with Mysql in PowerBI Service
Hi Team,
We successfully created a report in Power BI Desktop which included pre-exist visual theme and R scripts and while publishing the same in Power BI service, the R part is showing Script Runtime Error as cannot connect to Mysql server ( Which was successfully connected in Power BI Desktop). Kindly find the attached scrrenshots and error codes for your reference & revert at the earliest.
Script Runtime Error Details:
Script Runtime Error
Loading required package: DBI
Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to MySQL server on 'IP ADDRESS' (0)
Please try again later or contact support. If you contact support, please provide these details.
Activity ID: 1d8bd62a-6815-4412-a8b6-9e209c4eaeaa
Request ID: 00fb617b-8727-edff-6d5a-5f4563c13c7b
Correlation ID: 4330cf1c-574c-927e-bb08-2f86e467d3b5
Time: Fri Sep 06 2019 12:47:05 GMT+0530 (India Standard Time)
Version: 13.0.10668.164
Cluster URI: https://wabi-india-west-redirect.analysis.windows.net
USED R SCRIPT
library(RMySQL) library(ggplot2) conn <-dbConnect(MySQL(), user='user', password='user_123', dbname='test', host='localhost',port = 3308) rs = dbSendQuery(conn, "SELECT platform,day(sdate) as day,sum(val) as traffic FROM test.test_report where sdate>=date_format(curdate() - interval 1 day,'%Y-%m-01') group by platform,sdate") data=fetch(rs,n=-1) p<-ggplot(data=data, aes(x=day, y=traffic,color=platform)) + geom_bar(stat="identity", fill="white") p
WR,
Sathish R
- Anonymous6 years ago
Hi sathhishcse ,
Where are you r package library installed?(root folder or external folder) It seems like power bi service can't find out specific package functions located at xxxx.
In addition, you can also take a look at following document to know more about limitations of use r script on power bi service side:
Creating R visuals in the Power BI service
Regards,
Xiaoxin Sheng
2 Replies
- AnonymousNot applicable
Hi sathhishcse ,
Where are you r package library installed?(root folder or external folder) It seems like power bi service can't find out specific package functions located at xxxx.
In addition, you can also take a look at following document to know more about limitations of use r script on power bi service side:
Creating R visuals in the Power BI service
Regards,
Xiaoxin Sheng
- sathhishcseNew Member
Hi Xiaoxin Sheng,
Thanks for your reply.
We have fixed the issue by acknowleding the dataset for R script from Power BI report's datasource instead of creating a new datasource in R script. i.e We removed the Mysql DB connectivity part from script and used existing report's datasource for viz.
updated R Script
require("ggplot2") library(ggplot2) data=dataset p<-ggplot(data=data, aes(x=day, y=val,color=platform)) + geom_bar(stat="identity", fill="white") pThanks.
WR,
Sathish R