0
我目前正在使用Google應用引擎的內置分貝。看起來,當我運行put()
向數據庫中插入一個元組時,即使該元組還沒有被完全插入,該函數也會返回。下面的代碼:Google App Engine數據庫在返回之前不會執行完畢
new_user = Users(username=username_input, hashed_password=get_hashed_password(username_input, password))
new_user.put()
existing_user = None
while not existing_user:
print "existing_user still not in DB"
#tries to get the user that was put into the DB
existing_user = db.GqlQuery("SELECT * FROM Users WHERE username=:username_input", username_input=username_input).get()
print "existing_user in DB"
當我運行這段代碼,我得到下面的輸出,
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user still not in DB
existing_user in DB
爲什麼會出現這種情況? put()
不應該在返回之前將元組放入數據庫嗎?