connecting to local mariaDB database

I've recently installed MariaDB on my Macbook using the brew package installer.

I'm able to connect to a db client session locally via a terminal (and likewise create/ query tables, etc), but am having a tough time connecting to the db from my R session in RStudio

I'm using the RMariaDB package found at this github repo.

Any advice on why I can't create this connection in R is much appreciated.

library("RMariaDB")
library("DBI")

con <- DBI::dbConnect(RMariaDB::MariaDB(), username="root", password="", dbname ="test", host="localhost")

DBI::dbWriteTable(con, 'cars', mtcars, overwrite = T)

DBI::dbListTables(con)
#> Error in result_fetch(res@ptr, n = n): Error fetching buffer:

Created on 2018-11-29 by the reprex package (v0.2.1)

You have a missing driver statement

drv <- dbDriver("MySQL")
con <- dbConnect(drv, username="root", password="", dbname ="YOUR_DB_HERE", host="localhost")
1 Like

Hmmm. RMariaDB::MariaDB() was being passed to DBI::dbConnect as the driver in my original example, but it doesn't seem to work.

Your advice does, however, so thank you; maybe it's an issue with the MariaDB package for now.

1 Like

Hi @cawthm!

If your question's been answered, would you mind choosing a solution? It helps other people see which questions still need help, or find solutions if they have similar problems. Here’s how to do it:

Done. In this case my question wasn’t really answered since the behavior isn’t really explained and I wanted to let the question sit open for a minimum of 12 hours in case anyone else had anything enlightening to add.

But I guess I should now take that up on the github repo with the maintainers.

2 Likes

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