开发者

app engine python gql query not running

开发者 https://www.devze.com 2023-02-12 22:26 出处:网络
results_patientalerts = db.GqlQuery(\"SELECT * FROM PatientAlerts WHERE patientinfo_ID=\" + data_key + \" AND alert_type!=3\")

results_patientalerts = db.GqlQuery("SELECT * FROM PatientAlerts WHERE patientinfo_ID=" + data_key + " AND alert_type!=3")

patientinfo_ID is db.IntegerPrope开发者_如何转开发rty()

data_key is key which i got it from URL....


Inserting query arguments inline is generally a bad idea. A much better way is to let the db library do this for you:

results_patientalerts = db.GqlQuery("SELECT * FROM PatientAlerts WHERE patientinfo_ID = :1 AND alert_type != :2", data_key, 3)

By querying the database this way you avoid any query escaping, quoting and/or formatting issues, since it's done automatically.

As you didn't say what exactly doesn't work in this query I cannot say what the problem is with it, but it could be some sort of an issue related to the above.

0

精彩评论

暂无评论...
验证码 换一张
取 消