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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.