documentation hints for GAE dialect usage

Issue #2711 resolved
Former user created an issue

This is a follow-up from ticket http://www.sqlalchemy.org/trac/ticket/2649

I am trying to use sqlalchemy to access google cloud sql as an external program, i.e., not from google application engine. My understanding from http://stackoverflow.com/questions/10763171/can-sqlalchemy-be-used-with-google-cloud-sql is that this is a possible use case.

Is this a valid use case?

If so, I'd like to know what configuration steps are required in order to allow this to work. Perhaps this could be clarified in http://docs.sqlalchemy.org/en/rel_0_8/dialects/mysql.html?highlight=google%20cloud%20sql#module-sqlalchemy.dialects.mysql.gaerdbms

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.

I'm using sqlalchemy-0.8.0-py2.7-win32.egg on windows 8, with python 2.7.3

When I tried this, I get the exception documented in http://stackoverflow.com/questions/16129969/what-needs-to-be-installed-along-with-google-appengine-for-sqlalchemy-google-c , copied here for convenience

    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](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](k) = kwargs.pop(k)
    ---> 64             dbapi = dialect_cls.dbapi(**dbapi_args)
         65
         66         dialect_args['dbapi']('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

Comments (7)

  1. Mike Bayer repo owner

    Replying to Lou K:

    This is a follow-up from ticket http://www.sqlalchemy.org/trac/ticket/2649

    I am trying to use sqlalchemy to access google cloud sql as an external program, i.e., not from google application engine. My understanding from http://stackoverflow.com/questions/10763171/can-sqlalchemy-be-used-with-google-cloud-sql is that this is a possible use case.

    Is this a valid use case?

    sure, that's what we were going for when I fixed #2649.

    If so, I'd like to know what configuration steps are required in order to allow this to work.

    No idea, I don't use google app engine and the steps here would be the same as what you'd do if you wanted to develop with the google.storage APIs directly, so you'd want to read their docs/faqs/message boards for non-SQLAlchemy-specific instructions. The point at which SQLAlchemy actually calls upon the GAE libraries is what you see in #2649.

    Perhaps this could be clarified in http://docs.sqlalchemy.org/en/rel_0_8/dialects/mysql.html?highlight=google%20cloud%20sql#module-sqlalchemy.dialects.mysql.gaerdbms

    sure, if you get an answer on your stackoverflow question or similar, we can add tips to the documentation provided they aren't going to go out of date too quickly. the whole way things seem to be done seems pretty hacky.

    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.

    yeah that is all greek to me, for edge cases like GAE I rely upon the community to plug in the appropriate bits.

    When I tried this, I get the exception documented in http://stackoverflow.com/questions/16129969/what-needs-to-be-installed-along-with-google-appengine-for-sqlalchemy-google-c , copied here for convenience

    hopefully someone will follow up over there.

  2. Former user Account Deleted

    Maybe I am confused. After reading your response, I googled "google storage api python" and found https://developers.google.com/appengine/docs/python/googlestorage/overview , but this is written assuming the access to the cloud storage will be from an instance of the google application engine.

    After following those instructions, the google application engine SDK would be installed, but external python applications wouldn't know about it (i.e., the google packages are not in sys.path). Normally (as far as I understand it -- I'm a neophyte with GAE), one would test within a closed sandbox which can find the SDK, but other, external applications would not be able to find the SDK without taking the steps which I mentioned (your "greek" comment).

    What I'm asking is, what steps were taken in order to allow this code create_engine('mysql+gaerdbms:///mydb',...) to a google cloud sql database to be tested, from an external application, rather from the GAE environment.

    Is that not known?

    -- follow-up from above

    I found https://developers.google.com/api-client-library/python/start/installation which may have more information. I'll let you know if this is the installation which is needed.

  3. Former user Account Deleted

    From the author (Sean Lynch) on http://stackoverflow.com/questions/16129969/what-needs-to-be-installed-along-with-google-appengine-for-sqlalchemy-google-c :

    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.

    I found the following to work on windows (but I suspect it would work on other operating systems as well):

  4. Mike Bayer repo owner

    the GAE docs are as far as I need them to go (users of GAE need to know on their own what's up with their DBAPI) and also #2715 has addressed remaining import issues.

  5. Log in to comment