Connecting to Google Cloud SQL using a proxy with a key

I am trying to create a connection to Google Cloud SQL using a proxy with a key but the format of the connection string is giving me problems.

Is there anyone that has done this before that can provide me with some guidance?

I used the code below but can't workout where to include the proxy with the key? Think this is a stupid question but would like to get it to work as part of my data flow pipeline.

Where do I include the proxy and the key in the example as part of the documentation included below?

Load the DBI library

library(DBI)

Helper for getting new connection to Cloud SQL

getSqlConnection <- function(){
con <-
dbConnect(
RMySQL::MySQL(),
username = 'username',
password = 'password',
host = '127.0.0.1',
dbname = 'example'
) # TODO: use a configuration group group = "my-db")
return(con)
}

this is an interesting challenge...

There are lots of different proxy methods. When you connect using other tools, how do you connect through your proxy and add a key? Are you using this: https://cloud.google.com/sql/docs/mysql/sql-proxy ?

Given your example I presume you are using the MySQL implementation.

The documentation shows that you can start a service locally that establishes connection to the cloud service and opens a local port. You then connect to the local port:

https://cloud.google.com/sql/docs/mysql/quickstart-proxy-test

Can you make that work using the mysql command line syntax shown in the docs?

Hi JD,

I'm a bit out of my depth here.

I will go through the suggested material and see where that leads me.

Will revert soon.

Generally my approach to these types of things is to make sure I can connect using the method outlined in the provider documentation. If I can't do that then I debug that part first. After that's working then I try to get R connecting using a similar method. The principle is that you only want to be debugging one thing at a time or else you'll drive yourself mad.

Good luck and as you get more info, don't hesitate to circle back around with more questions!

This topic was automatically closed 21 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.