我尝试了Can SQLAlchemy be used with Google Cloud SQL?中的建议,使用sqlalchemy建立了与google cloud sql的外部连接。
为了让google appengine软件包可以访问我的环境,在安装google appengine sdk后,我将google目录复制到site-packages并创建了一个google.pth文件,其中包含带有“./google”的单行。随后可以看到Google软件包。
当我尝试执行create_engine调用时,出现以下异常。我的安装中缺少什么?我怎么能纠正这个?
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
答案 0 :(得分:1)
apiclient
是google-api-python-client的一部分,可以通过pip install google-api-python-client
安装,但客户端也与lib directory中的App Engine SDK捆绑在一起,并且是副本我用。我从未将我的App Engine安装移至site-packages,而是在PYTHONPATH
内添加.bash_profile
的路径,就像这样(我正在运行Mac):
export PYTHONPATH=/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine:$PYTHONPATH
还有一个Google Cloud SDK,它刚刚在几周前发布,其中包含了所有Google Cloud服务,包括Cloud SQL和App Engine。