Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
RossP96
Helper I
Helper I

Error when Getting Data from R Script which References MySQL Query

I'm trying to run an R script in Power BI which connects to multiple sources and then runs a GLM to return predictions in a new dataframe. Im struggling with debugging some of the errors im getting.

 

The latest one is "Error in sqlQuery - first argument is not an open RODBC channel"

I have connected to the server initially in script:

 

con <- DBI::dbConnect(odbc::odbc(),
Driver = "{MySQL ODBC 8.0 ANSI Driver}",
Server = "server name",
UID ="username",
Database = "database",
PWD = "password",
Port = 3306)

 

I have then used the following at the start of the SQL query:

 

dataframe_name <- sqlQuery (con,

"SELECT.....

 

Any ideas why im getting this error?

 

Thanks

2 REPLIES 2
RossP96
Helper I
Helper I

Update: ive now got the above working by moving to dbGetQuery, which is working for my first query. However the second query is giving me the error "Unable to translate bytes [A3] at index -1 from specified code page to Unicode." I've had a look online and cant see much for this error, any ideas?

Helpful resources

Announcements
December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.