I have a few .sql files which aggregate a number of tables/views in a SQL Database. I want to be able to direct R to a specific sql file and execute it and return the results in a dataframe.
Googling around it seems that I can only grab actual tables/views which are in the database or I have to rewrite the sql query and run that through the package RODBC.
In python this can be done with pd.read_sql_query
You can utilize the readr-package in conjunction with DBI and odbc
install.packages("readr")
library("DBI")
library("odbc")
library("readr")
df <- dbGetQuery(con, statement = read_file('Query.sql'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With