I tried the readLines and read.csv , but then it didn’t work.
Here is the contents of my_script.sql file:
SELECT EmployeeID, FirstName, LastName, HireDate, City FROM Employees WHERE HireDate >= '1-july-1993'
and it is saved on my desktop.
Now I want to run this request from my R script. Here is what I have:
conn = connectDb() fileName <- "C:\\Users\\me\\Desktop\\my_script.sql" query <- readChar(fileName, file.info(fileName)$size) query <- gsub("\r", " ", query) query <- gsub("\n", " ", query) query <- gsub("", " ", query) recordSet <- dbSendQuery(conn, query) rate <- fetch(recordSet, n = -1) print(rate) disconnectDb(conn)
And in this case, I get nothing. What can i try?
source share