我在Google雲數據存儲中有一個約50k行的實體,單獨不是GAE。我正在開始使用GAE進行開發,並且希望查詢此現有數據存儲,而無需將其導入GAE。我一直無法找到連接到現有數據存儲區種類的方式。從谷歌應用引擎查詢現有的Google雲數據存儲
從Hello World和其他指南改變的基本代碼即時通訊作爲一個POC工作。
import webapp2
import json
import time
from google.appengine.ext import ndb
class Product(ndb.Model):
type = ndb.StringProperty()
@classmethod
def query_product(cls):
return ndb.gql("SELECT * FROM Product where name >= :a LIMIT 5 ")
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
query = Product.query_product()
self.response.write(query)
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
返回的錯誤是
TypeError: Model Product has no property named 'name'
似乎是顯而易見的,它試圖用一個GAE數據存儲與實物產品,而不是我的產品現有的數據存儲已經定義的,但我不能找到如何使連接。
Andrei,感謝您爲我澄清這一點。我正在使用的應用程序與我的數據存儲在同一個項目中。我將再次查看文檔以嘗試查找我的問題。 –
轉到您的Google雲端平臺控制檯(https://console.cloud.google.com),並檢查您是否看到您的數據(位於「數據存儲>實體」下)。 –