Google Cloud SQL: Unable to connect

62 views
Skip to first unread message

Tom Campbell

unread,
Oct 21, 2015, 6:39:16 PM10/21/15
to web2py-users
My app is named todo.
I want to deploy it to GAE using Google Cloud SQL.
Connection looks like this:

if not request.env.web2py_runtime_gae:
    db = DAL(myconf.take('db.uri'), pool_size=myconf.take('db.pool_size', cast=int), check_reserved=['all'])
else:
    db = DAL('google:sql://gigcity-1951:dbtest/tomsdatabase')
    # etc.    

When I try to connect I get an "Internal error":

If I click the ticket link the ticket's missing.

Clue: It's not asking me for my Google credentials.

Sébastien

unread,
Oct 22, 2015, 12:43:46 PM10/22/15
to web2py-users
Is it happening locally? Did you install MySQLdb? 

I app.yaml you have to add under "libraries"

- name: MySQLdb
  version: "latest"

Finally you have to add your MySQL credential to dev_appserver.py like:

dev_appserver.py [root folder of web2py] --mysql_user=[mysql user] --mysql_password=[mysql password]



Tom Campbell

unread,
Oct 23, 2015, 5:48:50 PM10/23/15
to web2py-users
Thank you, Sébastien. I indeed had not used MySQLdb in app.yam, nor had I included credentials on the tried what you suggested and still get an error on the dev_appserver.py command line. Log files say this:

ERROR    2015-10-23 21:47:10,581 restricted.py:174] Traceback (most recent call last):

  File "/usr/local/web2py/gluon/restricted.py", line 227, in restricted

    exec ccode in environment

  File "/usr/local/web2py/applications/todo/models/db.py", line 27, in <module>

    db = DAL('google:sql://gigcity-1051:dbtest/tomsdatabase')

  File "/usr/local/web2py/gluon/packages/dal/pydal/base.py", line 174, in __call__

    obj = super(MetaDAL, cls).__call__(*args, **kwargs)

  File "/usr/local/web2py/gluon/packages/dal/pydal/base.py", line 473, 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 "/usr/local/web2py/gluon/packages/dal/pydal/base.py", line 446, in __init__

    self._adapter = ADAPTERS[self._dbname](**kwargs)

  File "/usr/local/web2py/gluon/packages/dal/pydal/adapters/base.py", line 60, in __call__

    obj = super(AdapterMeta, cls).__call__(*args, **kwargs)

  File "/usr/local/web2py/gluon/packages/dal/pydal/adapters/google_adapters.py", line 59, in __init__

    if do_connect: self.reconnect()

  File "/usr/local/web2py/gluon/packages/dal/pydal/connection.py", line 104, in reconnect

    self.connection = f()

  File "/usr/local/web2py/gluon/packages/dal/pydal/adapters/google_adapters.py", line 57, in connector

    return rdbms.connect(**driver_args)

TypeError: connect() got an unexpected keyword argument 'charset'



INFO     2015-10-23 21:47:10,581 gaehandler.py:75] **** Request: 5024.00ms/7.39ms (real time/cpu time)

INFO     2015-10-23 21:47:10,586 module.py:812] default: "GET /todo/default/index HTTP/1.1" 500 707

Reply all
Reply to author
Forward
0 new messages