0
stdin의 복사본을 사용하여 대량 데이터를 삽입하려고했지만 작동하지 않습니다. 는 아무도 내가 뭘 잘못 말해 줄 수 :stdin의 복사본이 libpqxx를 사용하는 C++의 postgres에 삽입되지 않습니다.
// Redirecting file input to stdin
std::ifstream in("infile.csv");
std::streambuf *cinbuf = std::cin.rdbuf(); // save old buffer
std::cin.rdbuf(in.rdbuf()); // redirect std::cin to in
std::string copyQuery("COPY tableName (col1,col2) FROM STDIN DELIMITER ',' CSV HEADER");
//Database connection
std::string conninfo("host=ip port=5432 dbname=tdb user=tdbuser password=tdbpsswd);
pqxx::connection conn(conninfo);
pqxx::work transaction(conn);
pqxx::result res = transaction.exec(copyQuery);
transaction.commit();
std::cin.rdbuf(cinbuf); // reset to standard input again
나는 테이블 내부에 삽입 할 데이터를 찾을 수 없습니다.
tablestreams는 최신 버전의 pqxx에서 더 이상 사용되지 않습니다. 대체품이 있습니까? –