Reputation: 11
Is there any sample insert into statement available to insert data to aws timestream tables. I am getting invalid syntax error.
Also aws documentation only provides samples with programming languages (Java,GO,Node,python) not SQL
Upvotes: 1
Views: 3186
Reputation: 2459
Inserts are currently (Dec 29 2022) supported via the WriteRecords
API only, which can either be called directly via the SDK, or via the CLI.
Below are two examples for inserting records via the CLI (reference), and what the resulting entries in the table will look like. For examples using the API, best refer to the official documentation as that provides code samples in various programming languages.
"Single-measure" record insert
aws timestream-write write-records \
--database-name mydatabase \
--table-name mytable \
--records '[{"Dimensions":[{"DimensionValueType": "VARCHAR","Name": "device-id","Value": "abc123"}],"MeasureName":"temperature","MeasureValue":"98.76","TimeUnit":"SECONDS","Time":"1672329484"}]'
device-id | measure_name | time | measure_value::double |
---|---|---|---|
abc123 | temperature_celsius | 2022-12-30 07:32:36.000000000 | 12.34 |
"Multie-measure" record insert
aws timestream-write write-records \
--database-name ab3-sensordata \
--table-name test1 \
--common-attributes '{"Dimensions":[{"Name": "device-id","Value": "abc123"}],"TimeUnit":"SECONDS","Time":"1672272000000"}' \
--records '[{"MeasureName":"device-data", "MeasureValueType":"MULTI","MeasureValues":[{"Name":"temperature_celsius", "Type":"DOUBLE", "Value":"12.34"},{"Name":"noise_decibel", "Type":"DOUBLE", "Value":"25.34"}]}]'
device-id | measure_name | time | temperature_celsius | temperature_celsius |
---|---|---|---|---|
abc123 | device-data | 2022-12-30 07:21:20.000000000 | 12.34 | 25.34 |
Upvotes: 4
Reputation: 61
AWS Timestream does not support the INSERT or any DDL and DML SQL statements. Data insertion into AWS Timestream is supported using AWS SDK.
Upvotes: 3