1

I tried the recommendations in Can SQLAlchemy be used with Google Cloud SQL? to bring up an external connection to google cloud sql using sqlalchemy.

To allow visibility of google appengine packages to my environment, after installing the google appengine sdk, I copied the google directory to site-packages and created a google.pth file which contains single line with './google'. The google packages were then visible.

When I try to do the create_engine call, I get the following exception. Is something missing in my install? How can I correct this?

create_engine('mysql+gaerdbms:///runningdb', connect_args={"fsrcrunning":"fsrcrunningdb"})

C:\Python27\lib\site-packages\sqlalchemy-0.8.0-py2.7-win32.egg\sqlalchemy\engine\__init__.pyc in create_engine(*args, **kwargs)
    330     strategy = kwargs.pop('strategy', default_strategy)
    331     strategy = strategies.strategies[strategy]
--> 332     return strategy.create(*args, **kwargs)
    333
    334

C:\Python27\lib\site-packages\sqlalchemy-0.8.0-py2.7-win32.egg\sqlalchemy\engine\strategies.pyc in create(self, name_or_url, **kwargs)
     62                 if k in kwargs:
     63                     dbapi_args[k] = kwargs.pop(k)
---> 64             dbapi = dialect_cls.dbapi(**dbapi_args)
     65
     66         dialect_args['dbapi'] = dbapi

C:\Python27\lib\site-packages\sqlalchemy-0.8.0-py2.7-win32.egg\sqlalchemy\dialects\mysql\gaerdbms.pyc in dbapi(cls)
     48             return rdbms_apiproxy
     49         else:
---> 50             from google.storage.speckle.python.api import rdbms_googleapi
     51             return rdbms_googleapi
     52

C:\Python27\lib\site-packages\google\storage\speckle\python\api\rdbms_googleapi.py in <module>()
     44         'PYTHONPATH when using this backend.')
     45
---> 46 from apiclient import errors
     47 from apiclient import http
     48 from apiclient import model

ImportError: No module named apiclient
Community
  • 1
  • 1
Lou K
  • 1,128
  • 2
  • 12
  • 31

1 Answers1

1

apiclient is part of the google-api-python-client which can be installed via pip install google-api-python-client, although the client is also bundled with the App Engine SDK in the lib directory and is the copy I use. I never move my App Engine install to site-packages but instead add the path to PYTHONPATH inside of .bash_profile, like so (I'm running a Mac):

export PYTHONPATH=/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine:$PYTHONPATH

There is also a Google Cloud SDK, which was just released a few weeks ago, which encompasses all the Google Cloud services, including Cloud SQL and App Engine.

Sean Lynch
  • 6,267
  • 2
  • 43
  • 45
  • installing google-api-python-client seemed to be required. apiclient was not found in the copied version 1.7.6 of the google app engine sdk. Also, I removed the version of the SDK in site-packages, and linked to it using a .pth file (I mention because I think this method may be more OS agnostic -- should have thought of it earlier). – Lou K Apr 22 '13 at 19:30
  • Are you using the App Engine launcher to start your app, or another WSGI server? The App Engine launcher updates your sys.path to include the libs directory, which may have been your issue. – Sean Lynch Apr 22 '13 at 19:33
  • I'm running the application from the windows command line (actually from the ipython command line now, but will be from windows eventually). It's not an app engine application, rather a standalone application. – Lou K Apr 22 '13 at 20:35