如何在Hasura Data Api中编写查询以根据用户的输入提供输出

时间:2018-02-17 10:03:00

标签: postgresql hasura

如何在Hasura数据api中编写postgres sql主体,以获取用户输入的结果。  sql查询类似于“从表名中选择moviedetails,其中movie_name ='用户输入的名称'。我想知道接受用户数据的结构

url = "https://data.incipiently69.hasura-app.io/v1/query"

这是查询

的json有效负载

requestPayload = {     “type”:“select”,     “args”:{         “表”:“收集”,         “列”: [             “概览”         ]     } }

设置标题

headers = {     “Content-Type”:“application / json” }

在resp

中进行查询和存储响应

resp = requests.request(“POST”,url,data = json.dumps(requestPayload),headers = headers)

resp.content包含json响应。

打印(resp.content)

1 个答案:

答案 0 :(得分:1)

您只需要在API查询的where子句中替换从用户输入中检索到的数据。

# Step 1: Compute the (encoding) distance between the anchor and the positive, you will need to sum over axis=-1

pos_dist = tf.square(tf.abs(tf.subtract(anchor,positive)))

# Step 2: Compute the (encoding) distance between the anchor and the negative, you will need to sum over axis=-1

neg_dist = tf.square(tf.abs(tf.subtract(anchor,negative)))

# Step 3: subtract the two previous distances and add alpha.

basic_loss = tf.subtract(pos_dist,neg_dist) + alpha

# Step 4: Take the maximum of basic_loss and 0.0. Sum over the training examples.

#printing the first  5 elements to debug

print(basic_loss[0,0:5].eval())
print(tf.maximum(basic_loss[0,0:5].eval(),0).eval())
loss = tf.reduce_sum(tf.maximum(basic_loss,0.0))