[R-SIG-Mac] Reading a MySQL table into R
marc_schwartz at me.com
Mon Jan 31 20:14:03 CET 2011
On Jan 31, 2011, at 12:56 PM, Luca Meyer wrote:
> I should first mention that I am not familiar with database management tools, nor with database solutions for Mac OS X.
> I currently have some data sitting on a MySQL Server version 5.0.51a-24+lenny4 I access through a web site using phpMyAdmin - 220.127.116.11. That is, the database is sitting remotely and I have to access the table containing the data several times during each day.
> How can I read this data into a R data.frame without having to use phpMyAdmin to download a csv file to my machine and then import it from there? Is there some SQL query I can run directly from R into MySQL?
> I have been looking at RMySQL, am I on the right track? Or should I be looking at something else?
There are essentially two methods:
2. RODBC (also on CRAN), which would allow you to connect to MySQL via an ODBC driver, which is available from:
Be aware that for the second option, you will need to obtain the correct 32 or 64 bit version of the ODBC driver, depending upon which version of R you are running on your Mac when you want to connect to the server.
If you elect to use RODBC, Prof. Ripley has created a very helpful vignette, which can be read after installation by using:
Lastly, for detailed assistance on R and databases, there is the r-sig-db list. More info here:
More information about the R-SIG-Mac