Cant access Google Cloud SQL on GAE application

52 views
Skip to first unread message

Bernardo Leon

unread,
Oct 13, 2017, 1:01:12 AM10/13/17
to web2py-users
Hello, me again. I am testing Google Cloud Platform along with pycharm (I added a new run configuration for gae inside pycharm) and I have the following model:

# -*- coding: utf-8 -*-
from gluon.tools import Auth

db = DAL('google:sql://trahello:trahello-db/trahello')

I have installed the google app engine local server and did their hello world tutorial so I think my installation is fine.

When I hit the run button my console gives no errors:

INFO     2017-10-13 04:40:50,304 sdk_update_checker.py:231] Checking for updates to the SDK.
INFO     2017-10-13 04:40:51,108 sdk_update_checker.py:259] The SDK is up to date.
INFO     2017-10-13 04:41:03,088 api_server.py:300] Starting API server at: http://localhost:36575
INFO     2017-10-13 04:41:03,146 dispatcher.py:251] Starting module "default" running at: http://127.0.0.1:8080
INFO     2017-10-13 04:41:03,147 admin_server.py:116] Starting admin server at: http://localhost:8000

but when I try to open my app url: http://localhost:8080/trahello I get the following error.

Traceback (most recent call last):
  File "/home/bernardo/PycharmProjects/w2p_trahello/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "/home/bernardo/PycharmProjects/w2p_trahello/web2py/applications/trahello/models/modelo.py", line 4, in <module>
    db = DAL('google:sql://trahello:trahello-db/trahello')
  File "/home/bernardo/PycharmProjects/w2p_trahello/web2py/gluon/packages/dal/pydal/base.py", line 170, in __call__
    obj = super(MetaDAL, cls).__call__(*args, **kwargs)
  File "/home/bernardo/PycharmProjects/w2p_trahello/web2py/gluon/packages/dal/pydal/base.py", line 475, in __init__
    "Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
  File "/home/bernardo/PycharmProjects/w2p_trahello/web2py/gluon/packages/dal/pydal/base.py", line 455, in __init__
    self._adapter = adapter(**kwargs)
  File "/home/bernardo/PycharmProjects/w2p_trahello/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 40, in __call__
    obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
  File "/home/bernardo/PycharmProjects/w2p_trahello/web2py/gluon/packages/dal/pydal/adapters/base.py", line 368, in __init__
    super(SQLAdapter, self).__init__(*args, **kwargs)
  File "/home/bernardo/PycharmProjects/w2p_trahello/web2py/gluon/packages/dal/pydal/adapters/base.py", line 50, in __init__
    self._initialize_(do_connect)
  File "/home/bernardo/PycharmProjects/w2p_trahello/web2py/gluon/packages/dal/pydal/adapters/google.py", line 32, in _initialize_
    super(GoogleSQL, self)._initialize_(do_connect)
  File "/home/bernardo/PycharmProjects/w2p_trahello/web2py/gluon/packages/dal/pydal/adapters/mysql.py", line 24, in _initialize_
    user = self.credential_decoder(m.group('user'))
IndexError: no such group

Since the google adapter inherits from MySQL adapter it tries to run the _initialize_ method of the MySQL adapter which in turn tries to get the user and the password from the Google SQL URI. Is this an expected behaviour? 

How good is the Google Cloud Platform support on web2py? I am using the most recent stable version: Version 2.15.4-stable+timestamp.2017.09.02.04.02.22

Thank you for any insight!

Massimo Di Pierro

unread,
Oct 18, 2017, 11:02:24 PM10/18/17
to web2py-users
I use mysql on google app engine all the time. I use mysqldb with latest web2py and dal without any issue.

That is not the right connection string. It should be more something like this:

google:MySQLdb://username:password@/dbname?unix_socket=/cloudsql/projectname:us-central1:dbinstanceid

Reply all
Reply to author
Forward
0 new messages