如何在 soci 中获取 table 的架构或行名称?

How can I get the schema or row names of a table in soci?

我正在尝试完成 ,并且我知道如何间接完成...如果我可以获得 table 的架构。

如何使用 soci 执行此操作?

我试过:

std::string i;
soci::statement st = (mSql->prepare <<
               "show create table tab;",
               soci::into(i));
st.execute();
while (st.fetch())
{   
         std::cout << i <<'\n';
}

但只打印了 "tab"。

我也试过这个,来自 GitHub 中的 Soci 文档:

soci::column_info ci;
soci::statement st = (mSql->prepare_column_descriptions(table_name), into(ci));

st.execute();
while (st.fetch())
{
    // ci fields describe each column in turn
}

但被告知 column_info 不是 soci 的成员。

我找到了下面的代码here

soci::row v;
soci::statement st = (mSql->prepare << "SELECT * FROM tab", into(v));
st.execute(true);  /* with data exchange */
unsigned int num_fields = v.size();
std::cout << "fields: " << num_fields << std::endl;
num_fields = (num_fields <= 9) ? num_fields : 9;
unsigned long num_rows = (unsigned long)st.get_affected_rows();
std::cout << "rows: " << num_rows << std::endl;
for (size_t i = 0; i < num_fields; ++i) {
    const soci::column_properties &props = v.get_properties(i);
    std::cout << props.get_name() << '\t';
}
std::cout << std::endl;

最后打印的是列的正确名称。