本文介绍了使用Python和SQLAlchemy从Google Cloud Function连接到Cloud SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我阅读了与从GCF连接到Cloud SQL中托管的MysQL有关的所有文档仍然无法连接.另外,尝试了与此相关的SQLAlchemy .我正在使用以下连接
I read all documentation related to connecting to MysQL hosted in Cloud SQL from GCF and still can't connect. Also, tried all hints in documentation of SQLAlchemy related to this.I am using the following connection
con = 'mysql+pymysql://USER:PASSWORD@/MY_DB?unix_socket=/cloudsql/Proj_ID:Zone:MySQL_Instance_ID'
mysqlEngine = sqlalchemy.create_engine(con)
我得到的错误是:
推荐答案
在获得Google支持的长期支持后,我们发现原因是:我们应该在没有任何防火墙规则的情况下启用对Cloud SQL的公共访问.它没有证件,可能使您发疯,但是支持团队的银弹说:它是beta版!
After a long thread with Google Support, we found the reason to be: simply we should enable public access to Cloud SQL without any firewall rule. It is undocumented and can drive you crazy, but the silver bullet for the support team is to say: it is in beta!
这篇关于使用Python和SQLAlchemy从Google Cloud Function连接到Cloud SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!