TL;DR
Instead of unlaoding the RMySql
package, explicitly set the sqldf
default driver option to SQLite
before calling the sqldf
function:
options(sqldf.driver = "SQLite")
sqldf("select * from df limit 6")
Explanation
If not explicitly defined, the sqldf
package decides which DB driver to use as follows:
If not specified then the "dbDriver" option is checked and if that is not
set then sqldf checks whether RPostgreSQL, RMySQL or RH2 is
loaded in that order and the driver corresponding to the first one
found is used. If none are loaded then "SQLite" is used. dbname=NULL
causes the default to be used.
In your case, RMySql
has already been loaded and sqldf
will try to use the MySQL DB and write into a schema called test
. Detaching and unloading the RMySQL
package is one option, but not necessary. As mentioned by @GaborGrothendieck in his comment, the easiest fix is to simply tell sqldf
which DB driver to use explicitly, i.e.
sqldf("select * from df limit 6", drv="SQLite")
To not always having to add drv="SQLite"
, you can permanently set the default driver for the session to SQLite
:
options(sqldf.driver = "SQLite")
head(acs)
to your question. Why do you need "RMySQL" ? – Otherwise?sqldf
and read the description of thedbname
argument, thedrv
argument and also the part two paragraphs above the References section that begins with "On MySQL..." – Subkingdom