你如何使用 libpqxx stream_to table 或 raw_table
How do you use libpqxx stream_to table or raw_table
我使用的是 libpqxx 版本 7.7.0。我想使用 stream_to 功能。当我按照 https://libpqxx.readthedocs.io/en/7.7.0/a01429.html I get a warning saying that the stream_to function is deprecated and I should be using table or raw_table. Although I'm really struggling to get those static functions to work, and I can't find any examples anywhere of how they are used. I've read the docs for the functions found at https://libpqxx.readthedocs.io/en/7.7.0/a01176.html#a34d7ca93963c0b5733a9ebcc10f2429b 上的示例进行操作时。有人知道如何使用该功能吗?
我能够弄清楚如何使用 raw_table 函数。它似乎比 table 命令简单得多。
std::vector<std::tuple<float, std::string>> data = testData();
pqxx::work transaction{ conn };
pqxx::stream_to stream = pqxx::stream_to::raw_table(transaction, "<schema>.<table>", "<col1>, <col2>,...");
for (auto &tuple : data) {
stream << tuple;
}
stream.complete();
transaction.commit();
我使用的是 libpqxx 版本 7.7.0。我想使用 stream_to 功能。当我按照 https://libpqxx.readthedocs.io/en/7.7.0/a01429.html I get a warning saying that the stream_to function is deprecated and I should be using table or raw_table. Although I'm really struggling to get those static functions to work, and I can't find any examples anywhere of how they are used. I've read the docs for the functions found at https://libpqxx.readthedocs.io/en/7.7.0/a01176.html#a34d7ca93963c0b5733a9ebcc10f2429b 上的示例进行操作时。有人知道如何使用该功能吗?
我能够弄清楚如何使用 raw_table 函数。它似乎比 table 命令简单得多。
std::vector<std::tuple<float, std::string>> data = testData();
pqxx::work transaction{ conn };
pqxx::stream_to stream = pqxx::stream_to::raw_table(transaction, "<schema>.<table>", "<col1>, <col2>,...");
for (auto &tuple : data) {
stream << tuple;
}
stream.complete();
transaction.commit();