我无法使用slashdb rest将数据插入到mysql数据库中。我收到来自iot服务的post请求,消息正文中包含json数据,post请求来自下面这段erlang代码:
Method = post,
URL = "http://xxxxxxx/api/v2/sensor_sql/_table/s1",
Header = [{"X-DreamFactory-Api-Key", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}],
Type = "application/json",
Body = MessageStr,
HTTPOptions = [],
Options = [],
R = httpc:request(Method, {URL, Header, Type, Body},HTTPOptions, Options),身体是这样的:
{“温度”:22.7,“湿度”:99.9},"TempUnit":"C"}
我需要使用slashdb将这些正文数据插入到我的数据库中。在slashdb查询中正确配置sql语句以执行此任务的方法是什么?
发布于 2020-08-05 20:06:20
好的,我自己解决了。要将json数据数组插入到mysql数据库中,您只需指定rest htlm地址(使用slashdb中的"Data Discovery“),并在post请求的主体中传递所有json数据。如果需要更新多个字段,请针对资源端点(单个记录)发出请求,并将JSON对象作为有效负载发送。下面是如何同时更新同一记录的BillingPostalCode和BillngCountry字段:
curl https://demo.slashdb.com/db/Chinook/Invoice/InvoiceId/1 -XPUT -i -H 'Content-Type: application/json' -d '{"BillingPostalCode": "456" "BillingCountry": "Germany"}'https://stackoverflow.com/questions/63230737
复制相似问题