python - Can't connect to CloudSQL (using GAE + Django) -


the problem

i unable connect cloudsql via django in google app engine (flexible) on production server. using python 3 if makes difference.

i'm using example in settings.py:

databases = {     'default': {         'engine': 'django.db.backends.mysql',         'host': '/cloudsql/<your-project-id>:<your-cloud-sql-instance>',         'name': '<your-database-name>',         'user': 'root',     } } 

(with ids filled in, of course.)

when used socket, unable connect @ all:
can't connect local mysql server through socket '/cloudsql/projectid:cloudsqlid' (2)

when tried using ipv4 instead of socket, able connect database, error:
lost connection mysql server @ 'reading initial communication packet'

even stranger, when tried connecting cloudsql on local server (using ipv4 of course), able connect fine. it's deployed app giving me trouble.

here's app.yaml

runtime: python threadsafe: true vm: true entrypoint: gunicorn -b :$port myapp.wsgi:app  runtime_config:   python_version: 3 

confusion

it says <your-cloud-sql-instance>, i'm assuming means id of sql instance. noticed on "overview" sql instance, says instance connection name: projectid:us-central1:cloudsqlid. tried using connection name in place of <your-project-id>:<your-cloud-sql-instance> no luck.

here's quote google app engine docs specific cloudsql , django:
the google cloud sql instance you're connecting, in format '/cloudsql/your-project-id:your-instance-name' or '/cloudsql/domain:your-project-id:your-instance_name'.

here says there 2 ways of connecting via socket (why? i'm not sure), adding "domain:" doesn't seem either.

i can't sure tried every combination of variations above, it's possible missed something.

i prefer connect via socket, not ipv4.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -