[R] From within R, what are "good" ways to run SQL code contained in a text file?

Jeff Newmiller
Wed, 18 May 2022 18:52:33 -0000

Running external SQL files that you modify on the fly is almost certainly not a
good idea because you should not be parameterizing with string manipulation but
with dedicated parameterization code (e.g. [1]). Otherwise you risk encountering
Little Bobby Tables
(https://www.explainxkcd.com/wiki/index.php/Little_Bobby_Tables). Since this
requires custom R code anyway, I reject the whole premise of your question.

[1] https://cran.r-project.org/web/packages/DBI/vignettes/DBI-advanced.html

On May 18, 2022 10:01:10 AM PDT, Kelly Thompson <kt1572757 at gmail.com>
wrote:
>I am interested in this topic and found this post on StackOverflow,
>https://stackoverflow.com/questions/44853322/how-to-read-the-contents-of-an-sql-file-into-an-r-script-to-run-a-query
>
>This response seems especially useful,
>https://stackoverflow.com/a/44886192/10816734
>
>I'm curious about the thoughts and insights people here in r-help have
>about this question and topic, and to learn if there are "better"
ways
>than what is suggested in the StackOverflow thread.
>
>Thank you!
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

--
Sent from my phone. Please excuse my brevity.