I'm trying to select an entity from one table of the datastore, get some information out of it, and then put that information into an entity in a different table. The put() and get() methods don't seem to be working though and I can't figure out why.
aName = 'Hello'
q = firstTable.all()
q.filter("date =", datetime.date.today())
dateInfo = q.get() #get method here works fine
p = db.GqlQuery("SELECT * FROM secondTable WHERE name = '%s'" % aName)
result = p.run(limit = 1) #here, there's an error if I use get(), but no error if I use run()
result.firstProperty = dateInfo.firstProperty
result.secondProperty = dateInfo.secondProperty
result.put() #this line does not work
You error is because
run causes the query to be run, returning an iterator which
you need to iterate over the results. It doesn't directly return an entity.
In your case you are trying to update the iterator itself and then call
which of course fails.
Even with a limit of 1, you need to iterate.
You should be using get, however you point out you get an error.
error: raise BadValueError('Property %s is required' % self.name) BadValueError: Property info is required
This will be because you have changed a property in your model
info and added
required=True but you have some old data in the datastore that has no value for
You problem has a lot to do with trying/changing too many things at once without really understanding what is going on. I suggest you go back and read the docs on queries and their methods, and remove
required=True from your
info property in the model until such time as you can update all the entities so that
info has a value.