title: How to copy a database table from a disk database to a in "memory" database in R?
body: <p>My question relates to how one can copy over (often referred to as attach) a table from a <strong>disk database</strong> to one that you create in <strong>memory</strong>.</p>
  
  <p>I have seen this done in Python, but am yet to solve it in R.</p>
  
  <p>My following example is this;</p>
  
  <p>I would like to copy over the table <em>mtcars</em> from the <strong>disk database .db file called "test.sqlite"</strong> </p>
  
  <p>To a in <strong>memory</strong> database.</p>
  
  <pre><code>library(DBI) 
  
  # Create an on disk RSQLite database 
  
  con &lt;- dbConnect(RSQLite::SQLite(), "test.sqlite.db") 
  
  dbWriteTable(con, "mtcars", mtcars) 
  
  dbListTables(con)
  
  #so at this point i have the mtcars table in my disk database. 
  
  I would like to now copy it over into a in memory databse;
  
  mem_conn &lt;- dbConnect(RSQLite::SQLite(), ":memory:")
  
  #stuck here on how to copy over a table
  </code></pre>
  
  <p>Is there a way of copying over the mtcars table from my disk db file to the memory one. The only way i can think is to load the data into an R object then dbWriteTable to the new in memory database. </p>
  
  <p>Although that may not work as the data increases in size.</p>
  
  <p>Thank you in advance, if you got any tips!</p>
  
  <p>For reference using sqlite and R 64 bit</p>