about dbWriteTable won't read observants from dataframe

I just find out about connecting database from MySQL to R using RMySQL package. As someone that hates to input data manually to table in MySQL, I find the features quite fascinating, but I have some limitation, dbWriteTable is suppose to export your R data frame to table in MySQL db, but in my case they don't put the rows/records in the table, they only created table frame with the data type but zero rows. I tried to export more simple data frame with only 7 variables and 7 observant and they still won't read the rows, they only export table frame from my data frame. Why's so?

The code is like this:

con <- dbConnect(MySQL(), user = "user",
                 password = "pass",
                 dbname = "database",
                 host = "localhost",
                 port = 3306)
worldPhones <- data.frame(worldPhones)
dbWriteTable(con, "worldPhones", worldPhones, row.names = FALSE)

ps. I already tried to find the solution of this problem across all site and video but no one quite giving me the answer so I seek to get it from you guys, I hope one of you can find where's the problem is. Thanks beforehand.

That should work with the DBI and RMySQL loaded. Confirm that worldPhones isn't empty? Or try with mtcars. Don't forget to close con.

Is there any accompanying error message, warning, or note of any kind ?

They've this message:

Error in .local(conn, statement, ...) : could not run statement: Loading local data is disabled; this must be enabled on both the client and server sides

But they still run the code, which created table frame (again) without the value on it...

you probably need to go to your database and enable local loading, I think theres a local-infile setting

1 Like

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.