[英]How to write a query in Hasura Data Api to give output based on input by user
How to write the postgres sql body in Hasura data api to get some result by taking input from user. 如何在Hasura数据api中编写postgres sql主体,以通过从用户获取输入获得一些结果。 The sql query is like"Select moviedetails from table name where movie_name='name enterd by user'.I want to know the structure to accept data from user
sql查询就像“从表名中选择moviedetails,其中movie_name ='用户输入的名称”。我想知道从用户那里接受数据的结构
url = "https://data.incipiently69.hasura-app.io/v1/query"
requestPayload = { "type": "select", "args": { "table": "collect", "columns": [ "overview" ] } } requestPayload = {“ type”:“ select”,“ args”:{“ table”:“ collect”,“ columns”:[“ overview”]}}
headers = { "Content-Type": "application/json" } 标头= {“ Content-Type”:“ application / json”}
resp = requests.request("POST", url, data=json.dumps(requestPayload), headers=headers) resp = request.request(“ POST”,url,data = json.dumps(requestPayload),headers = headers)
print(resp.content) 打印(resp.content)
You would just need to substitute data retrieved from the user input in the where clause of the API query. 您只需要替换从API查询的where子句中的用户输入中检索到的数据。
user_input = req.body.user_input
requestPayload = {
"type": "select",
"args": {
"table": "collect",
"columns": ["overview", "movie_name"],
"where": {
"movie_name": user_input
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.