문제

If i want to run a GqlQuery with a variable i've set is that possible?

for example:

myNumber = 4

myResult = db.GqlQuery("SELECT * from myData WHERE filter = myNumber")

this results in:

Parse Error: Invalid WHERE condition at symbol

Am i going about this all wrong? Thanks for your time.

도움이 되었습니까?

해결책

According to The Google Appengine Documentation, your code might look like this:

myNumber = 4
myResult = db.GqlQuery("SELECT * FROM myData WHERE filter = :num", num=myNumber)

or

myNumber = 4
myResult = db.GqlQuery("SELECT * FROM myData WHERE filter = :1", myNumber)

depending on whether you want to use a named or positional variable.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top