Monday, June 8, 2020

[google-cloud-sql-discuss] Re: Can't connect over mysql-connector-python

Hello Emre, 


From your query it is appearing you are trying to connect from MySQL database located in Compute Engine instance to Cloud SQL instance. 


This document provides instructions on how to connect from Compute Engine to Cloud SQL instance. It is also possible to connect from External Applications to the Cloud SQL instance by using the proxy, by configuring access for one or more public IP addresses, busing the JDBC Socket Factory (for the Java programming language) or by using the Cloud SQL Proxy library (for the Go programming language). You can get more information on this here



On your specific query on MySQL Connector/Python you can get further information on this MySQL site where this document provides a coding example for connecting to MySQL Using Connector/Python.


If still the issue is not resolved or If you have any technical queries or think your issue is related to code, you can post at the Stack Overflow or Server Fault and a community of developers will assist you.


In case there are any technical issues or you would like to request any feature you can report it at the Public Issues by selecting the right component here


Please also note that Google Groups forum is meant for general discussion of the platform, not specific technical issues. You can find more info about Community Support Overview on Google Groups here.



On Monday, June 8, 2020 at 8:25:40 AM UTC-4, Emre Akbaş wrote:
I am very new to mysql I always use nosql db options I had a lot of issues and at the end when I am comfortable I want to let go of whole auto backup multi region config stuff to google and start to try cloud sql while everything is ok with private ip connections and such. I can connect from compute instances by mysql -h -u -p command but can't connect with mysql-connector-python 

this is what I used for connection string I am trying to find solutions without putting proxy and a lot of complication between if that's possible.

import mysql.connector
import config as cfg

def connect_db():
    mydb = mysql.connector.connect(
        host=cfg.config["sql"],
        user=cfg.config["user"],
        passwd=cfg.config["password"],
        database=cfg.config["db"],
        connection_timeout=300,
        )
    return mydb

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/386d4cee-dc0d-47b2-b37a-81d5043f68a8o%40googlegroups.com.

No comments:

Post a Comment