>>109897089
I made a small library which lets you compile the program with either SQLite or Postgres support. query is made by doing db->query or db->queryRows and passing in the sql statement along with args, like this:
for (auto file_tuple : db->queryRows<std::tuple<std::string, std::optional<int>, std::optional<int>, std::optional<std::string>>>("SELECT file_name, width, height, thumbnail_file_extension FROM message_file WHERE message_id = $1", message_id)) {
message_files.push_back(File{
.filename = std::get<0>(file_tuple),
.width = std::get<1>(file_tuple),
.height = std::get<2>(file_tuple),
.thumbnail_file_extension = std::get<3>(file_tuple)
});
The downside is you can only stick to a subset of the language where Postgres and SQLite behave the same way.