python-docs-samples icon indicating copy to clipboard operation
python-docs-samples copied to clipboard

django cloud sql sample for postgresql

Open staticmetal opened this issue 9 years ago • 43 comments

Please add sample for django postgresql settings.

I tried the instructions at: https://cloud.google.com/appengine/docs/flexible/python/using-cloud-sql-postgres

But they are not working. I am getting unix socket error. More details: http://stackoverflow.com/questions/42950418/postgres-settings-for-django-on-google-app-engine-flexi

staticmetal avatar Mar 22 '17 12:03 staticmetal

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

Dean-Christian-Armada avatar Sep 28 '18 10:09 Dean-Christian-Armada

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 avatar Jan 20 '20 23:01 ibci

Solved, the problem was that in my HOST i used the region as "eu-west6" instead of "europe-west6"

ibci avatar Jan 21 '20 09:01 ibci