Hyperion
Hyperion

Reputation: 5

Insert DATE format using libpqxx and c++

I get a std::vector< std::vectorstd::string > and want to stream this to the database using pqxx::stream_to (pretty huge amount of data) e.g:

  pqxx::work insert_tx(C);
  pqxx::stream_to stream{
     insert_tx,"CompTable",std::vector<std::string>{"TKey", "AKey"}};
  
  for (auto&& row : vector_of_vectors)
  {
     auto val = std::make_tuple(row.at(3),row.at(2));
     stream<<val;
  }
  stream.complete();
  insert_tx.commit();

This works fine as long there is no "DATE" format needed. I know i can do it with SQL statements e.g (".... VALUES ($1::date)",std::string) but this doesn't work with pqxx::stream_to

So does anyone know which c++ datatype or struct or whatever is compatible with the SQL data format?

Thank you for your time and ideas :)

Upvotes: 0

Views: 845

Answers (1)

Seok
Seok

Reputation: 1

It just works using the string format "yyyy/MM/dd" or "yyyy-MM-dd" or some other format, maybe the count of second (you can see it in java.sql.date).

Upvotes: 0

Related Questions