R connection to Myqsl

Asked

Viewed 203 times

4

Does anyone know how #Mysql can have access to a dataframe that was handled in R, I have already connected to the following script

install.packages("RMySQL")
install.packages("RJDBC")

library(DBI)
library(RMySQL)
library(RJDBC)
mydrv <- dbDriver("MySQL")
conn <- dbConnect(mydrv, dbname= "" ,host="****",port=3306, user="***",password="***")

So far, I still don’t see R frames dates in Mysql.

Can someone help me?

  • If the connection is ok, you can list the Mysql tables with the function dbListTables, pull tables from MYSQL to R with dbGetQuery or dbGetTable

  • Are you creating an SQL db or want to make a connection to a database via odbc? If this is the first option, you need to write the data in the newly created database running DBI::dbWriteTable(). In the second case, @Danielfalbel explained well.

  • Thank you so much for your answers, it worked

1 answer

1

R (fortunately) will not load all database tables into memory. If your connection is ok you can use the function dbListTables() package DBI to list all tables.

To pull to memory can use: dbGetTable or dbGetQuery.

If you have created a connection with an empty database. You can write tables using dbWriteTable.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.