Skip to content

How to use the C++ API's prepared statement with parameters? #5167

Closed Answered by mewim
b3n-h4il asked this question in Q&A
Discussion options

You must be logged in to vote

Here is a concrete example:

#include "kuzu.hpp"
#include <iostream>
using namespace kuzu::main;
using namespace kuzu::common;

int main(int argc, char **argv)
{
   auto database = std::make_unique<Database>(":memory:", SystemConfig());
   auto connection = std::make_unique<Connection>(database.get());
   auto query = "RETURN $1, $2, $3";
   std::unordered_map<std::string, std::unique_ptr<Value>> params;
   params["1"] = std::make_unique<Value>(int64_t(1));
   params["2"] = std::make_unique<Value>(float(3.14159));
   params["3"] = std::make_unique<Value>(std::string("Hello, World!"));

   auto prepared_statement = connection->prepare(query);
   auto result = connection->executeWithParams(p…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by mewim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants