Insert table
Please refer to the detail of the API Request endpoint and params
Test Table
curl -o - http://127.0.0.1:5654/db/query \
--data-urlencode \
"q=create tag table EXAMPLE (name varchar(40) primary key, time datetime basetime, value double)"
About Time
The time stored in the sample files saved in these examples is represented in Unix epoch, measured in seconds. Therefore, when loading the data, it should be performed with the timeformat=s
option specified. If the data has been stored in a different resolution, this option needs to be modified to ensure proper input. Note that in Machbase Neo, the default time resolution is assumed to be in nanoseconds (ns)
and is executed accordingly.
Insert JSON file with epoch time
Prepare data file
data-epoch-1.json
download
{
"data": {
"columns":["NAME","TIME","VALUE"],
"rows": [
["wave.sin",1676432361,0],
["wave.sin",1676432362,0.406736],
["wave.sin",1676432363,0.743144],
["wave.sin",1676432364,0.951056],
["wave.sin",1676432365,0.994522]
]
}
}
Post data
curl -X POST "http://127.0.0.1:5654/db/write/EXAMPLE?timeformat=s" \
-H "Content-Type: application/json" \
--data-binary "@data-epoch-1.json"
Select rows
curl -o - http://127.0.0.1:5654/db/query \
--data-urlencode "q=select * from EXAMPLE"
Insert CSV file with epoch time and header
If csv data has header line like below, set the heading=true
query param.
Prepare data file
data-epoch-1-header.csv
download
NAME,TIME,VALUE
wave.sin,1676432361,0.000000
wave.cos,1676432361,1.000000
wave.sin,1676432362,0.406736
wave.cos,1676432362,0.913546
wave.sin,1676432363,0.743144
Post data
curl -X POST "http://127.0.0.1:5654/db/write/EXAMPLE?timeformat=s&heading=true" \
-H "Content-Type: text/csv" \
--data-binary "@data-epoch-1-header.csv"
Insert CSV file with epoch time and no header
If csv data has header line like below, set the heading=false
query param.
Prepare data file
data-epoch-1-no-header.csv
download
wave.sin,1676432361,0.000000
wave.cos,1676432361,1.000000
wave.sin,1676432362,0.406736
wave.cos,1676432362,0.913546
wave.sin,1676432363,0.743144
Post data
curl -X POST "http://127.0.0.1:5654/db/write/EXAMPLE?timeformat=s&heading=false" \
-H "Content-Type: text/csv" \
--data-binary "@data-epoch-1-no-header.csv"
Append a large CSV file
When loading a large CSV file, using the “append” method can allow data to be input several times faster compared to the “insert” method.
Prepare data file
data-epoch-bulk.csv
download
wave.sin,1676432361,0.000000
wave.cos,1676432361,1.000000
wave.sin,1676432362,0.406736
wave.cos,1676432362,0.913546
wave.sin,1676432363,0.743144
......
Post data
curl -X POST "http://127.0.0.1:5654/db/write/EXAMPLE?timeformat=s&heading=false&method=append" \
-H "Content-Type: text/csv" \
--data-binary "@data-epoch-bulk.csv"
Insert CSV file in default time format
Prepare data file
data-timeformat-1.csv
download
wave.sin,2023-02-15 03:39:21,0.111111
wave.sin,2023-02-15 03:39:22.111,0.222222
wave.sin,2023-02-15 03:39:23.222,0.333333
wave.sin,2023-02-15 03:39:24.333,0.444444
wave.sin,2023-02-15 03:39:25.444,0.555555
Post data
curl -X POST "http://127.0.0.1:5654/db/write/EXAMPLE?heading=false&timeformat=Default" \
-H "Content-Type: text/csv" \
--data-binary "@data-timeformat-1.csv"
Select rows
curl -o - http://127.0.0.1:5654/db/query \
--data-urlencode "q=select * from EXAMPLE" \
--data-urlencode "timeformat=Default" \
--data-urlencode "format=csv"
NAME,TIME,VALUE
wave.sin,2023-02-15 03:39:21,0.111111
wave.sin,2023-02-15 03:39:22.111,0.222222
wave.sin,2023-02-15 03:39:23.222,0.333333
wave.sin,2023-02-15 03:39:24.333,0.444444
wave.sin,2023-02-15 03:39:25.444,0.555555
Insert CSV file in default timeformat with Time Zone
Prepare data file
data-timeformat-1-tz-seoul.csv
download
wave.sin,2023-02-15 12:39:21,0.111111
wave.sin,2023-02-15 12:39:22.111,0.222222
wave.sin,2023-02-15 12:39:23.222,0.333333
wave.sin,2023-02-15 12:39:24.333,0.444444
wave.sin,2023-02-15 12:39:25.444,0.555555
Post data
curl -X POST "http://127.0.0.1:5654/db/write/EXAMPLE?heading=false&timeformat=Default&tz=Asia/Seoul" \
-H "Content-Type: text/csv" \
--data-binary "@data-timeformat-1-tz-seoul.csv"
Select rows in UTC
curl -o - http://127.0.0.1:5654/db/query \
--data-urlencode "q=select * from EXAMPLE" \
--data-urlencode "timeformat=Default" \
--data-urlencode "format=csv"
NAME,TIME,VALUE
wave.sin,2023-02-15 03:39:21,0.111111
wave.sin,2023-02-15 03:39:22.111,0.222222
wave.sin,2023-02-15 03:39:23.222,0.333333
wave.sin,2023-02-15 03:39:24.333,0.444444
wave.sin,2023-02-15 03:39:25.444,0.555555
Insert CSV file in RFC3339
time format
Prepare data file
data-timeformat-rfc3339.csv
download
wave.sin,2023-02-15T03:39:21Z,0.111111
wave.sin,2023-02-15T03:39:22Z,0.222222
wave.sin,2023-02-15T03:39:23Z,0.333333
wave.sin,2023-02-15T03:39:24Z,0.444444
wave.sin,2023-02-15T03:39:25Z,0.555555
Post data
curl -X POST "http://127.0.0.1:5654/db/write/EXAMPLE?heading=false&timeformat=RFC3339" \
-H "Content-Type: text/csv" \
--data-binary "@data-timeformat-rfc3339.csv"
Select rows in UTC
curl -o - http://127.0.0.1:5654/db/query \
--data-urlencode "q=select * from EXAMPLE" \
--data-urlencode "format=csv" \
--data-urlencode "timeformat=RFC3339"
NAME,TIME,VALUE
wave.sin,2023-02-15T03:39:21Z,0.111111
wave.sin,2023-02-15T03:39:22Z,0.222222
wave.sin,2023-02-15T03:39:23Z,0.333333
wave.sin,2023-02-15T03:39:24Z,0.444444
wave.sin,2023-02-15T03:39:25Z,0.555555
Insert CSV file in RFC3339Nano
time format with America/New_York
Prepare data file
data-timeformat-rfc3339nano-tz-newyork.csv
download
wave.sin,2023-02-14T22:39:21.000000000-05:00,0.111111
wave.sin,2023-02-14T22:39:22.111111111-05:00,0.222222
wave.sin,2023-02-14T22:39:23.222222222-05:00,0.333333
wave.sin,2023-02-14T22:39:24.333333333-05:00,0.444444
wave.sin,2023-02-14T22:39:25.444444444-05:00,0.555555
Post data
curl -X POST "http://127.0.0.1:5654/db/write/EXAMPLE?heading=false&timeformat=RFC3339Nano&tz=America/New_York" \
-H "Content-Type: text/csv" \
--data-binary "@data-timeformat-rfc3339nano-tz-newyork.csv"
Select rows in America/New_York
curl -o - http://127.0.0.1:5654/db/query \
--data-urlencode "q=select * from EXAMPLE" \
--data-urlencode "format=box" \
--data-urlencode "timeformat=RFC3339Nano" \
--data-urlencode "tz=America/New_York"
+----------+-------------------------------------+----------+
| NAME | TIME | VALUE |
+----------+-------------------------------------+----------+
| wave.sin | 2023-02-14T22:39:21-05:00 | 0.111111 |
| wave.sin | 2023-02-14T22:39:22.111111111-05:00 | 0.222222 |
| wave.sin | 2023-02-14T22:39:23.222222222-05:00 | 0.333333 |
| wave.sin | 2023-02-14T22:39:24.333333333-05:00 | 0.444444 |
| wave.sin | 2023-02-14T22:39:25.444444444-05:00 | 0.555555 |
+----------+-------------------------------------+----------+
Insert CSV file in custom time format
Prepare data file
data-timeformat-custom-1.csv
download
wave.sin,2023-02-15 03:39:21,0.111111
wave.sin,2023-02-15 03:39:22.111111111,0.222222
wave.sin,2023-02-15 03:39:23.222222222,0.333333
wave.sin,2023-02-15 03:39:24.333333333,0.444444
wave.sin,2023-02-15 03:39:25.444444444,0.555555
Post data
curl -X POST "http://127.0.0.1:5654/db/write/EXAMPLE?heading=false&timeformat=Default" \
-H "Content-Type: text/csv" \
--data-binary "@data-timeformat-custom-1.csv"
Select rows in UTC
curl -o - http://127.0.0.1:5654/db/query \
--data-urlencode "q=select * from EXAMPLE" \
--data-urlencode "format=csv" \
--data-urlencode "timeformat=Default"
+----------+-------------------------+----------+
| NAME | TIME | VALUE |
+----------+-------------------------+----------+
| wave.sin | 2023-02-15 03:39:21 | 0.111111 |
| wave.sin | 2023-02-15 03:39:22.111 | 0.222222 |
| wave.sin | 2023-02-15 03:39:23.222 | 0.333333 |
| wave.sin | 2023-02-15 03:39:24.333 | 0.444444 |
| wave.sin | 2023-02-15 03:39:25.444 | 0.555555 |
+----------+-------------------------+----------+
Insert CSV file in custome time format with America/New_York
Prepare data file
data-timeformat-custom-2.csv
download
hour:min:sec-SPLIT-year-month-day
format in newyork timezone
wave.sin,10:39:21-SPLIT-2023-02-14 ,0.111111
wave.sin,10:39:22.111111111-SPLIT-2023-02-14 ,0.222222
wave.sin,10:39:23.222222222-SPLIT-2023-02-14 ,0.333333
wave.sin,10:39:24.333333333-SPLIT-2023-02-14 ,0.444444
wave.sin,10:39:25.444444444-SPLIT-2023-02-14 ,0.555555
Post data
curl -X POST "http://127.0.0.1:5654/db/write/EXAMPLE?heading=false&timeformat=03:04:05.999999999-SPLIT-2006-01-02&tz=America/New_York" \
-H "Content-Type: text/csv" \
--data-binary "@data-timeformat-custom-2.csv"
Select rows in UTC
curl -o - http://127.0.0.1:5654/db/query \
--data-urlencode "q=select * from EXAMPLE" \
--data-urlencode "format=csv" \
--data-urlencode "timeformat=2006-01-02 03:04:05.999999999"
NAME,TIME,VALUE
wave.sin,2023-02-14 03:39:21,0.111111
wave.sin,2023-02-14 03:39:22.111111111,0.222222
wave.sin,2023-02-14 03:39:23.222222222,0.333333
wave.sin,2023-02-14 03:39:24.333333333,0.444444
wave.sin,2023-02-14 03:39:25.444444444,0.555555
select rows in default time format in America/New_York Time Zone
curl -o - http://127.0.0.1:5654/db/query \
--data-urlencode "q=select * from EXAMPLE" \
--data-urlencode "format=csv" \
--data-urlencode "timeformat=Default" \
--data-urlencode "tz=America/New_York"
NAME,TIME,VALUE
wave.sin,2023-02-14 10:39:21,0.111111
wave.sin,2023-02-14 10:39:22.111,0.222222
wave.sin,2023-02-14 10:39:23.222,0.333333
wave.sin,2023-02-14 10:39:24.333,0.444444
wave.sin,2023-02-14 10:39:25.444,0.555555