使用 slashdb rest api 将 json 数据插入 MySQL 数据库
Insert json data into MySQL database with slashdb rest api
我无法使用 slashdb rest 将数据插入 mysql 数据库。
我从我的物联网服务收到一个 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},"温度单位":"C"}
并且我需要使用 slashdb 将这些主体的数据插入到我的数据库中。
在 slashdb 查询中正确配置我的 sql 语句以执行此任务的方法是什么?
ok我自己解决了。
要将 json 数据数组插入到您的 mysql 数据库中,您只需要指定您的其余 html 地址(在 slashdb 中使用“数据发现”)并在正文中传递所有 json 数据您的 post 请求。
如果您需要更新多个字段,请针对资源端点(单个记录)发出请求,并将 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"}'
我无法使用 slashdb rest 将数据插入 mysql 数据库。 我从我的物联网服务收到一个 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},"温度单位":"C"}
并且我需要使用 slashdb 将这些主体的数据插入到我的数据库中。 在 slashdb 查询中正确配置我的 sql 语句以执行此任务的方法是什么?
ok我自己解决了。 要将 json 数据数组插入到您的 mysql 数据库中,您只需要指定您的其余 html 地址(在 slashdb 中使用“数据发现”)并在正文中传递所有 json 数据您的 post 请求。 如果您需要更新多个字段,请针对资源端点(单个记录)发出请求,并将 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"}'