- assigned issue to
- changed milestone to 0.8.xx
- changed component to documentation
- changed title to documentation hints for GAE dialect usage
- marked as minor
documentation hints for GAE dialect usage
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)
-
repo owner -
repo owner - changed milestone to 0.x.xx
-
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?
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.
-
repo owner Replying to Lou K:
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?
I think it is known, but not by me, you'd need to talk to the guy who opened
#2649and also answered http://stackoverflow.com/a/10900826/34549 (I think it's the same person). -
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):
- install google application engine SDK found at https://developers.google.com/appengine/downloads#Google_App_Engine_SDK_for_Python (note directory gae gets placed in)
- create google_appengine.pth file with pointer to directory used above (causes sys.path to include this directory)
- easy_install --upgrade google-api-python-client (pip install google-api-python-client should also work)
-
repo owner - changed status to wontfix
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
#2715has addressed remaining import issues. -
repo owner - changed milestone to 1.x.xx
- Log in to comment
Replying to Lou K:
sure, that's what we were going for when I fixed
#2649.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.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.
yeah that is all greek to me, for edge cases like GAE I rely upon the community to plug in the appropriate bits.
hopefully someone will follow up over there.