GeezerVison is showing github.com — django cloud sql sample for postgresql · Issue #870 · GoogleCloudPlatform/python-docs-samples
django cloud sql sample for postgresql #870Activitytheacodes commented on Mar 22, 2017 agmathew commented on Mar 23, 2017 ryanmats commented on Mar 23, 2017 @KushGoyal @agmathew thanks for the feedback. i'll take a look at this today. ryanmats commented on Mar 24, 2017 @KushGoyal @agmathew So I was able to get it to work when deployed, and wasn't able to reproduce your error message :/
I would recommend doing the Django on App Engine Flexible tutorial (https://cloud.google.com/python/django/flexible-environment) from the beginning step-by-step with these PostgreSQL specific changes:
-
When you get to 'Create a Cloud SQL Instance' step 1, use https://cloud.google.com/sql/docs/postgres/create-instance and make sure you create a PostgreSQL instance instead of a Cloud SQL instance. When you create the instance, you'll be asked to create a password. This password is for the 'postgres' default user for this PostgreSQL instance.
-
Skip step 2 of 'Create a Cloud SQL Instance,' since you set the password when creating the instance.
-
In 'Initialize your Cloud SQL instance' step 1, use this command to use port 5432 instead of 3306: "./cloud_sql_proxy -instances="[YOUR_INSTANCE_CONNECTION_NAME]"=tcp:5432"
-
In 'Configure the Database Settings,' when you are editing mysite/settings.py, also change 'ENGINE': 'django.db.backends.mysql' to 'ENGINE':'django.db.backends.postgresql'
-
While you are configuring database settings here, also edit your requirements.txt file and add psycopg2==2.7.1
If you do this and still have difficulties, let us know along with more details about where you got stuck and what error messages you got! staticmetal commented on Mar 24, 2017 @ryanmats it worked! Although I didn't change a thing 😲
Thanks for the help Reacted by Daniel Khashabi agmathew commented on Mar 24, 2017 @ryanmats Same for me, it's working now, but I haven't touched anything. Do you know if any changes were made to GAE or CloudSQL Postgres in the last few days? Is there somewhere where we can track changes like this? We're currently evaluating whether to use GAE for a new product and I'm a little concerned about a service "fixing" itself. ryanmats commented on Mar 24, 2017 @KushGoyal @agmathew Great to hear that it works! I just filed a bug for the Cloud SQL / Postgres team to ask them about this - will let you know what they say.
@jonparrott do you know if there are any resources for customers to track product changes? (see @agmathew 's comment above) theacodes commented on Mar 24, 2017 theacodes commented on Mar 24, 2017 (Closing as this appears to be resolved, but feel free to comment if you have any more questions/issues). staticmetal commented on Apr 19, 2017 The issue is repeating again on a new project. I have followed the exact steps which are:
-
create a postgresql instance
-
create a db
-
get name of connection using command: gcloud sql instances describe <instance-name>
-
add connection name to app.yaml
beta_settings:
cloud_sql_instances: <connection-name>
- use host as
/cloudsql/<connection-name>
Reacted by Ramiel and Alexander Kell staticmetal commented on Apr 19, 2017 I tried to deploy the project again and this time it worked without changing anything.
I don't know what changed. Perhaps this issue is related to app engine not detecting the presence of postgresql db. ryanmats commented on Apr 19, 2017 @KushGoyal we'll ping the CloudSQL engineering team about this. thanks for the feedback. ankushagarwal commented on Apr 19, 2017 @KushGoyal :
- What was the error message that you received?
- What was the format of the SQLALCHEMY_DATABASE_URI that you used (eg: postgresql+psycopg2://username:password@/databasename?host=connection-name)
- Did you try connecting to the instance from your local machine by using cloud-sql-proxy? (look at the Setting up your local environment instructions here : https://cloud.google.com/appengine/docs/flexible/python/using-cloud-sql-postgres)
DanielJoyce commented on Feb 23, 2018 Encountered this bug as well, with a ruby app Reacted by jo and Patrick Nollet DaskJeeves commented on May 2, 2018 Still getting this issue. What is the solution here? japhiaolson commented on May 4, 2018 Still getting this issue here as well. ClubOfRome commented on May 16, 2018 MacOS 10.13.4
Django 1.11.10
Postgres 9.6.3
I have not been able to connect to cloud_sql_proxy at other than port 5432.
So, I have to stop my local postgres server to free the port. DaskJeeves commented on May 17, 2018 Strangely enough, my cloud_sql_proxy connects on 5434, while my local db connects at 5433. And when I deploy I have it set to 5432. Quite the system ClubOfRome commented on May 17, 2018 Makes sense to me. I have to shut down my local postgres to use the proxy.
…AngelosP commented on May 18, 2018 @ryanmats I ran into the exact same problem as @KushGoyal because of a bug on this Google Cloud Console page:

Link to page
In this page it's impossible to unselect Woo-Server. Because I didn't want to enable the SQL API on Woo-Server I cancelled out of this dialog and tried to enable it through the API library:

Now, I'm not 100% sure what happened next but somehow I had the API enabled (it was listed as enabled), but as far as App Engine was concerned it was disabled ... hence the "could not connect to server: No such file or directory" error message.
After reading @ryanmats reply I remembered cancelling out of the first dialog in Google Cloud Console. So I went back to the tutorial, used it despite the bug of not allowing me to unselect Woo-Server and now it works fine. So for everyone running into the same issue, just make sure you enable the Google SQL API this way. kurtisvg commented on May 18, 2018 You should be able to customize the port the proxy connects on by editing the instance connection string: <INSTANCE_CONNECTION_NAME>=tcp:<PORT>.
There are probably differences in the connection string needed depending on using TCP sockets or using Unix sockets, but these will depend on the library being used. Dean-Christian-Armada commented on Sep 28, 2018 In my case, it was solved when I put the configuration below in app.yml
beta_settings:
cloud_sql_instances: "<connection-name>"
Dean-Christian-Armada commented on Sep 28, 2018 Another tip is to check the logs of the container of your cloud_sql when you are in a flex environment like
docker logs --tail=100 -f 810ae3237e94
2018/09/28 10:40:29 Ready for new connections
2018/09/28 10:40:30 errors parsing config:
googleapi: Error 403: Access Not Configured. Cloud SQL Admin API has not been used in project 636840238029
before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/sqladmin.googleapis.
com/overview?project=636840238029 then retry. If you enabled this API recently, wait a few minutes for the action t
o propagate to our systems and retry., accessNotConfigured
ibci commented on Jan 20, 2020 I'm still getting this error... I've tried everything I've seen so far:
- enabling SQL APIs (admin and component) + credentials
- psycopg2==2.8.4
- set 'ENGINE': 'django.db.backends.postgresql_psycopg2',
- set beta_settings at the end of the app.yaml
- checked 'docker logs --tail' and just seeing "Ready for new connections" without any error
I can connect to the DB if I run cloud_sql_proxy locally, and it works perfectly.
My django version is: Django-3.0.
I'm desperate... if somebody could help... :) ibci commented on Jan 21, 2020 Solved, the problem was that in my HOST i used the region as "eu-west6" instead of "europe-west6" locked as resolved and limited conversation to collaborators on Jan 21, 2020
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|