本文介绍了将django连接到Google Cloud SQL第二代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在使用 Cloud SQL第二代。 Django在appspot上运行,当在本地主机上测试时,与数据库的连接工作正常。我也可以将mysql客户端连接到远程实例,创建数据库,创建用户,通常的东西。我甚至可以远程上传装置。 但是我无法在连接到SQL实例的appspot上获取django。 尝试此操作时: code> DATABASES = {'default':{'ENGINE':'django.db.backends.mysql','INSTANCE':'instance:connection:name' ,'NAME':'database','USER':'dbuser','PASSWORD':'pass',} } 我得到一个 OperationalError :当尝试这样: DATABASES = {'default':{' ENGINE':'django.db.backends.mysql','NAME':'database','USER':'dbuser','PASSWORD':'pas s','HOST':'1.2.3.4',#我的SQL实例IPv4地址} } 我得到一个 OperationalError : > DATABASES = {'default':{'ENGINE':'django.db.backends.mysql' ,'NAME':'database','USER':'dbuser','PASSWORD':'pass','HOST':'/ cloudsql / my -instance-id',} } 我得到一个code> OperationalError :什么是 DATABASES 在使用Google Cloud SQL Second Generation时用于django的设置? 编辑 有一个描述所需的设置,但我会说这是第一代。 此外,还有一个相关问题,但也适用于第一代。 p> EDIT2 我看到,默认情况下,云SQL第二代没有授权应用程序,那里无法在Google Cloud Platform控制台上授权应用程序。这可能是连接不起作用的原因。不幸的是,我还不知道如何授权第二代实例的应用程序。 EDIT3 试图授权应用程序: gcloud sql实例补丁< sql-instance> - gae-apps< gae-app> 但不幸的是:不知道如何为第二代解决方案是第一代和第二配置中的不同配置。我有同样的问题,通过更改实例的名称修复它: / cloudsql / [INSTANCE_CONNECTION_NAME] 在您必须授权应用引擎应用程序之前。 来源。 I am using a Cloud SQL Second generation. Django is running on the appspot, and connection to the database is working fine when testing on the localhost. I can also connect with the mysql client to the instance remotely, create databases, create users, the usual stuff. I can even remotely upload fixtures.But I am unable to get django on the appspot connected to the SQL instance.When trying this:DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'INSTANCE': 'instance:connection:name', 'NAME': 'database', 'USER': 'dbuser', 'PASSWORD': 'pass', }}I get an OperationalError:When trying this:DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'database', 'USER': 'dbuser', 'PASSWORD': 'pass', 'HOST': '1.2.3.4', # my SQL instance IPv4 address }}I get an OperationalError:When trying this:DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'database', 'USER': 'dbuser', 'PASSWORD': 'pass', 'HOST': '/cloudsql/my-instance-id', }}I get an OperationalError:What are the DATABASES settings to use for django when using a Google Cloud SQL Second Generation?EDITThere is a page describing the required settings, but I would say that is for First Generation.Also, there is a related question, but that applies also for First Generation.EDIT2I have seen that by default there are no "Authorized applications" for Cloud SQL Second Generation, and there is no option to authorize an application on the Google Cloud Platform console. This could be the reason why connections are not working. Unfortunately I do not yet know how to authorize an application for Second Generation instances.EDIT3Trying to authorize applications:gcloud sql instances patch <sql-instance> --authorized-gae-apps <gae-app>But unfortunately:No idea how to this for Second Generation 解决方案 are different configurations in the first generation and the second configuration. I had the same problem and fix it by changing the name of the instance:/cloudsql/[INSTANCE_CONNECTION_NAME]Before you have to authorize the app engine application.Source. 这篇关于将django连接到Google Cloud SQL第二代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 16:36
查看更多