Jeff Newmiller
2022-May-18 18:52 UTC
[R] From within R, what are "good" ways to run SQL code contained in a text file?
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 (explainxkcd.com/wiki/index.php/Little_Bobby_Tables). Since this requires custom R code anyway, I reject the whole premise of your question. [1] 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, >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, >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 >stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.-- Sent from my phone. Please excuse my brevity.
Kelly Thompson
2022-May-18 20:18 UTC
[R] From within R, what are "good" ways to run SQL code contained in a text file?
Jeff, Thanks. Please, can you elaborate and explain what you mean when you say "I reject the whole premise of your question". On Wed, May 18, 2022 at 11:52 AM Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:> > 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 (explainxkcd.com/wiki/index.php/Little_Bobby_Tables). Since this requires custom R code anyway, I reject the whole premise of your question. > > [1] 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, > >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, > >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 > >stat.ethz.ch/mailman/listinfo/r-help > >PLEASE do read the posting guide R-project.org/posting-guide.html > >and provide commented, minimal, self-contained, reproducible code. > > -- > Sent from my phone. Please excuse my brevity.