title: how to send a query from a .sql file?
body: <h3>background:</h3>
  <p>I am using RMySQL to query a database; I have been doing this successfully with quoted strings, but I would now like to send a longer query from a .sql file.</p>
  <p>The sql file is in <code>mypackage/inst/extdata/myquery.sql</code></p>
  <h3>question:</h3>
  <p>What is the best way to import the query from <code>myquery.sql</code> and submit it to a database?</p>
  <h3>What I have tried:</h3>
  <p>Here is the function that I am working on:</p>
  <pre><code>library(RMySQL)
  library(mypackage)
  
  myqueryfun &lt;- function(...){
     file    &lt;- system.file(&quot;extdata&quot;, &quot;myquery.sql&quot;, package = &quot;mypackage&quot;)
     query   &lt;- SOMEFUN(file)
     con     &lt;- dbConnect(...)
     q       &lt;- dbSendQuery(con, query)
     result  &lt;- fetch(q, n = -1)
     return(result)
  }
  </code></pre>
  <p>So, I am looking for the function <code>SOMEFUN</code> and its additional parameters. I have tried <code>scan</code> and <code>readLines</code>, and I have tried different arguments to these functions, such as <code>scan(file, sep = '\n', what = 'character')</code> The closest that I have gotten is <code>writeLines(readLines(file))</code>, but I get some error related to parsing the file, like the response to <code>writeLines(readLines())</code>:</p>
  <pre><code>Error in function (classes, fdef, mtable)  : 
    unable to find an inherited method for function &quot;dbSendQuery&quot;, for signature &quot;MySQLConnection&quot;, &quot;NULL&quot;
  Called from: stop(&quot;unable to find an inherited method for function \&quot;&quot;, fdef@generic, 
      &quot;\&quot;, for signature &quot;, cnames)
  </code></pre>
  <p>If the query is a character vector of length 1, such as <code>&quot;show tables;&quot;</code>, I get the expected output.</p>