使用Python和SQLAlchemy从Google Cloud Function连接到Cloud SQL

编程入门 行业动态 更新时间:2024-10-22 08:27:02
本文介绍了使用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)

我得到的错误是:

(pymysql.err.OperationalError)(2003,无法连接到'localhost'上的MySQL服务器([Errno 111]连接被拒绝)")(此错误的背景位于: sqlalche.me/e/e3q8 )

推荐答案

在获得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

本文发布于:2023-10-24 19:49:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1524841.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:连接到   Google   SQLAlchemy   Python   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!