codyfeng/kdb-cpp

How to manipulate strings using kdp-cpp

Malacarne opened this issue · 1 comments

Hello codyfeng, suppose I want to insert multiple rows of data using a for-loop in C++. How can it be done using your code? I'll show below what I'm trying so far:

1) connect and create a table with two columns of integer values;

kdb::Connector kcon;
kcon.connect(HOST_ADDR, HOST_PORT);
kcon.sync("tbl2:([]a:10 20 30;b:40 50 60)");

2) use a for loop to insert new rows of data:

for (int = 0; i < 100; i++)
{
kcon.sync("`tbl2 insert ("+std::to_string(i)+";"+std::to_string(i*2)+")");
}

But when I try to compile the code I get the following error:

error: no matching function for call to ‘kdb::Connector::sync(std::__cxx11::basic_string<char>)’
kcon.sync("`tbl2 insert ("+std::to_string(i)+";"+std::to_string(i*2)+")");

Regards,
Malacarne

Just solved the problem... :-)

string newData = "`tbl2_cpp insert ("+std::to_string(i)+";"+std::to_string(i*2)+")";
kcon.sync(newData.c_str());