influxdb-cxx icon indicating copy to clipboard operation
influxdb-cxx copied to clipboard

An error occurred when I query the database

Open cqfive opened this issue 4 years ago • 5 comments

My Code:

auto influxdb = influxdb::InfluxDBFactory::Get("http://localhost:8086/?db=test");
std::vector<influxdb::Point> points = influxdb->query("SELECT * FROM test");
cout << points.size() << endl;

And this is the structure of measurement "test":

select *from test
name: test
time                host      value
----                ----      -----
1583938657323591874 localhost 10
1583938681385599260 localhost 10

Error message:

g++ QueryTest.cc -o QueryTest -std=c++17 -lInfluxDB
./QueryTest 

terminate called after throwing an instance of ' 
boost::wrapexcept<boost::property_tree::json_parser::json_parser_error>' what():  <unspecified file>(1): garbage after data
Aborted (core dumped)

This is my environment:

gcc 7.3
boost 1.72.0
curl 7.69.1

What should I do to solve this problem, thanks.

cqfive avatar Mar 18 '20 04:03 cqfive

Sorry missed that, I'll take a look tomorrow!

awegrzyn avatar Mar 19 '20 21:03 awegrzyn

Are you sure your database name is test as well? Because you only showed that your measurement name = test. Could you also try running ./bin/testQuery and lemme know what the output is?

awegrzyn avatar Mar 20 '20 19:03 awegrzyn

Are you sure your database name is test as well? Because you only showed that your measurement name = test. Could you also try running ./bin/testQuery and lemme know what the output is?

Yes, the database is 'test'. The result of testQuery is as follows:

root@ubuntu:/home/SourceCode/influxdb-cxx/build/bin# ls
benchmark  testFactory  testHttp  testPoint  testQuery  testUdp

root@ubuntu:/home/SourceCode/influxdb-cxx/build/bin# ./testQuery 
Running 1 test case...
unknown location(0): fatal error: in "query1": std::logic_error: basic_string::_M_construct null not valid
/home/SourceCode/influxdb-cxx/test/testQuery.cxx(18): last checkpoint

*** 1 failure is detected in the test module "Test InfluxDB Query"

Thanks :-)

cqfive avatar Mar 21 '20 02:03 cqfive

Could you try with v0.5.0 ?

awegrzyn avatar Mar 21 '20 09:03 awegrzyn

Could you try with v0.5.0 ?

I have sent a mail to your mailbox, please check it.

cqfive avatar Mar 21 '20 10:03 cqfive