简体   繁体   English

libpqxx库中没有pqxx :: tuple?

[英]No pqxx::tuple in libpqxx library?

I ve got the newest ubuntu and I ve done: ve got the newest ubuntu and I已经完成:

sudo apt-get install postgresql postgresql-contrib
sudo apt-get install libpqxx-4.0v5
sudo apt-get install libpqxx-dev

I can`t compile program which uses pqxx::tuple. 我无法编译使用pqxx :: tuple的程序。

Compilation: 汇编:

g++ test.cpp -I/usr/local/include/ -lpqxx -lpq
or
g++ test.cpp -lpqxx -lpq -o test

Console output: 控制台输出:

test.cpp: In function ‘int main()’:
test.cpp:15:21: error: ‘tuple’ in namespace ‘pqxx’ does not name a type
const pqxx::tuple row = r[rownum];

This is the problematic line: 这是有问题的行:

const pqxx::tuple row = r[rownum];

When I remove this line, program works correctly. 当我删除此行时,程序可以正常工作。

#include <iostream>
#include <pqxx/pqxx>
int main()
{
  try {
    pqxx::connection c("dbname=mydb user=postgres port=5432 password=*** hostaddr=127.0.0.1");
    pqxx::work w(c);
    pqxx::result r = w.exec("SELECT * FROM get_player_data_function()");
    w.commit();
    const int num_rows = r.size();
    for (int rownum=0; rownum < num_rows; ++rownum) {
        const pqxx::tuple row = r[rownum];
    }
  }
  catch (const std::exception &e) {
    std::cerr << e.what() << std::endl;
  }
}

Not sure... but if I understand correctly this page , you have to substitute pqxx::tuple with pqxx::row . 不确定...但是如果我正确理解此页面 ,则必须用pqxx::row代替pqxx::tuple

So, I suppose 所以,我想

const pqxx::row row = r[rownum];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM