我目前正在使用Google应用引擎的内置数据库。似乎当我运行put()
将元组插入数据库时,即使元组尚未完全插入,函数也会返回。这是代码:
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()
不应该将元组放入数据库中吗?