Reputation: 11
I am a beginner with InfluxDB. When I use shell "EOF" to access influxdb, but it thow out an error error parsing query: found use, expected SELECT, DELETE, SHOW, CREATE, DROP, GRANT, REVOKE, ALTER, SET, KILL at line 1, char 1
.
Here is the script as follows
influx << EOF
use testdb
insert test,altitude=1000,area=北 temperature=11,humidity=-4
EOF
Did not influx support interactive processing in shell?
Upvotes: 1
Views: 2005
Reputation: 153
You can't use USE
or INSERT
when piping into influx. These commands (and others) are specific to the interactive command line and disabled when stdin is not a tty.
You need to save data to a text file and use -import
option:
influx -host=localhost -port=8086 -import -path data.txt
where data.txt should look like this:
# DML
# CONTEXT-DATABASE: testdb
test,altitude=1000,area=北 temperature=11,humidity=-4
See the documentation for details.
Alternatively, you can directly use the HTTP API via curl:
curl -XPOST "http://localhost:8086/write?db=testdb" --data-binary @- << EOF
test,altitude=1000,area=北 temperature=11,humidity=-4
EOF
Upvotes: 3