Reputation: 11
I use prepared statement to save 1 entity to database
_connection.prepare("save", "INSERT INTO public.table (col1, col2, col3) VALUES ($1, $2, $3)");
Then in my Save function I do:
void DBRepository::Save(const DBEntity &entity)
{
pqxx::work w(_connection);
try
{
w.exec_prepared("save",
entity.col1(),
entity.col2(),
entity.col3());
w.commit();
}
catch (const std::exception &e)
{
std::cerr << e.what() << '\n';
}
}
I want to use use lipqxx::stream_to utility in a bulk insert function
void DBRepository::BulkInsert(const std::vector<DBEntity>) { ... }
as stated in the linked question i get a deprecated warning if i use the sample code in the libpqxx documentation.
For the accepted answer, how can I convert to my data into convenient tuple and use my prepared statement to avoid escaping ?
Upvotes: 1
Views: 162