1
我想在App Engine上構建應用程序,該應用程序使用Cloud SQL作爲後端數據庫而不是App引擎自己的數據存儲設施(不支持常見的SQL操作,如加入)。導入web2py的DAL用於App Engine上的Google Cloud SQL
雲SQL有一個DB-API,因此我一直在尋找一個輕量級的數據抽象層(DAL)來幫助輕鬆操縱雲數據庫。一個小小的研究表明,web2py有一個與Cloud SQL兼容的漂亮DAL。
因爲我實際上並不需要整個全棧的web2py框架,我複製了dal.py從/膠子文件夾中的文件進行到一個簡單的測試應用程序的主目錄,其中包括此行中我的應用程序:
from dal import DAL, Field
db=DAL('google:sql://myproject:myinstance/mydatabase')
但是,這在我部署應用程序並嘗試運行後產生了一個錯誤。
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/_webapp25.py", line 701, in __call__
handler.get(*groups)
File "/base/data/home/apps/jarod-helloworld/2.357593994022416181/helloworld2.py", line 13, in get
db=DAL('google:sql://serangoon213home:rainman001/guestbook')
File "/base/data/home/apps/jarod-helloworld/2.357593994022416181/dal.py", line 5969, in __init__
raise RuntimeError, "Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
File "/base/data/home/apps/jarod-helloworld/2.357593994022416181/dal.py", line 5956, in __init__
self._adapter = ADAPTERS[self._dbname](*args)
File "/base/data/home/apps/jarod-helloworld/2.357593994022416181/dal.py", line 3310, in __init__
self.folder = folder or '$HOME/'+thread.folder.split('/applications/',1)[1]
File "/base/python_runtime/python_dist/lib/python2.5/_threading_local.py", line 199, in __getattribute__
return object.__getattribute__(self, name)
AttributeError: 'local' object has no attribute 'folder'
它看起來像它的錯誤是由於與由語句指定的「文件夾」屬性
self.folder = folder or '$HOME/'+thread.folder.split('/applications/',1)[1]
有誰知道這個屬性做什麼,我怎麼能解決這個問題?