Giter VIP home page Giter VIP logo

Comments (3)

hafermoraes avatar hafermoraes commented on July 26, 2024 1

Hello,

To @kforner and all the other poor souls like me fighting to connect using SSL, I did finally manage to connect using the following strategy.

Before proceeding, update the DBI and RMariaDB libraries to the last version using the devtools from within R.

  1. obtain the file rds-combined-ca-bundle.pem here and save it to disk on your home directory.

  2. provide a configuration file named db.conf (or whatever name you prefer) on your home directory having the following content

[connection_name]
database=database_name
host=your_host_address
user=your_user_name
password=your_password
ssl_ca=/path/to/rds-combined-ca-bundle.pem
  1. connect to the database via DBI and RMariaDB from R:
## install.packages("devtools")
## devtools::install_github("r-dbi/DBI")
## devtools::install_github("r-dbi/RMariaDB")

library(DBI)
library(RMariaDB)

mydb <- dbConnect(
    RMariaDB::MariaDB() 
   ,default.file = '/path/to/db.conf'
   ,group = 'connection_name'
)
## test the connection
dbGetQuery(mydb,'show tables;')

Hope that helps.

Best regards,
Rafael R. de Moraes

from rmysql.

kforner avatar kforner commented on July 26, 2024

Hello,
Any comment on this ?
I spent a lot of time providing a complete reproducible example with the mysql server and clients configured...

from rmysql.

kforner avatar kforner commented on July 26, 2024

for what it's worth, here's my connect function:

mysql_connect <- function(..., drv = MariaDB(), ssl = FALSE, ssl.ca = get_rds_ssl_certificates_bundle()) {
#mysql_connect <- function(..., drv = MariaDB()) {
  ### ... can be a list of params or a list of a list of params
  ### we make sure to always a list of params
  args <- list(...)
  if (length(args) == 1 && is.list(args[[1]])) args <- args[[1]]
  
  if (is.null(args$drv)) args$drv <- drv
  if (!is.null(args$ssl)) {
    ssl <- args$ssl
    args$ssl <- NULL
  }

  # dbConnect has a bug with a relative default.file
  if (!is.null(args$default.file)) {
    first_char <- substr(args$default.file, 1, 1)
    if (first_char != .Platform$file.sep) # relative path
      args$default.file <- paste0('.', .Platform$file.sep, args$default.file)
  }

  if (ssl) {
    if (is.null(args$ssl.ca)) args$ssl.ca <- ssl.ca
  }
  
  do.call(DBI::dbConnect, args)
}

from rmysql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.