I am getting an error message " error in evaluating the argument 'drv' in selecting a method for function 'dbConnect': could not find function "MySQL""

Here is the part of the code:

library(DBI) 
conn <- dbConnect( drv = RMySQL::MySQL(), dbname = "xxx", host = "xxx", username = "xxx", password = "new_password") 
dbGetQuery(conn, "SELECT * FROM tech LIMIT 1;") 
dbDisconnect(conn)
1

There are 1 best solutions below

0
On

If you're using a script in an interactive session, call library(RMySQL) to load the package.

If you get this error while developing a package, add RMySQL to the Imports field of your DESCRIPTION file. You can do that with usethis::use_package("RMySQL").