title: Loading several SQL tables from a database in R
body: <p>I have a local mysql database with some tables in it. I can load the tables one a time like so:</p>
  <pre><code>library(DBI)
  library(odbc)
  library(RODBC)
  
  myconn1 &lt;- odbcConnect(&quot;mysqldsn&quot;)
  employees &lt;- sqlQuery(myconn1, &quot;SELECT * FROM employees;&quot;)
  customers &lt;- sqlQuery(myconn1, &quot;SELECT * FROM customers;&quot;)
  </code></pre>
  <p>I want to load all the tables from the database into a list in R. I am trying to use a for loop to do so:</p>
  <pre><code>list_tables &lt;- list()
  
  for (i in sqlQuery(myconn1, &quot;SHOW TABLES;&quot;)){
    list_tables[[i]] &lt;- sqlQuery(myconn1, paste(&quot;SELECT * FROM&quot;, i,&quot;;&quot;))
  }
  </code></pre>
  <p>However, I get the error:
  Error in <code>[[&lt;-</code>(<code>*tmp*</code>, i, value = sqlQuery(myconn1, paste(&quot;SELECT * FROM&quot;,  :
  no such index at level 1</p>
  <p>I know that I do not have a representative dataset but I am not sure how to upload an sql database on stackoverflow.</p>