Functions
query_result_t.cc File Reference
#include "cetlib/container_algorithms.h"
#include "cetlib/sqlite/Connection.h"
#include "cetlib/sqlite/ConnectionFactory.h"
#include "cetlib/sqlite/column.h"
#include "cetlib/sqlite/create_table.h"
#include "cetlib/sqlite/insert.h"
#include "cetlib/sqlite/query_result.h"
#include "cetlib/sqlite/select.h"
#include <cassert>
#include <memory>
#include <string>
#include <utility>
#include <vector>

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

int main ( void  )

Definition at line 21 of file query_result_t.cc.

22 {
24  unique_ptr<Connection> c{cf.make_connection(":memory:")};
25  string const name{"numbers"};
26  vector<pair<string, int>> const pairs{{"one", 1}, {"five", 5}, {"ten", 10}};
27  create_table(*c, name, column<string>("key"), column<int>("value"));
28  for (auto const& pr : pairs) {
29  insert_into(*c, name).values(pr.first, pr.second);
30  }
31  query_result<string, int> allEntries;
32  allEntries << select("*").from(*c, name);
33  cet::for_all_with_index(allEntries,
34  [&pairs](size_t const i, auto const& row) {
35  auto const [key, value] = row;
36  assert(key == pairs[i].first);
37  assert(value == pairs[i].second);
38  });
40  create_table_as("onlyValues", select("value").from(*c, name));
41  cet::for_all_with_index(values, [&pairs](size_t const i, auto const& row) {
42  auto const& v = get<0>(row);
43  assert(v == pairs[i].second);
44  });
45 }
static QCString name
Definition: declinfo.cpp:673
auto insert_into(sqlite3 *const db, std::string const &tablename)
Definition: insert.h:110
void for_all_with_index(FwdCont &, Func)
auto make_connection(std::string const &file_name, PolicyArgs &&...) -> Connection *
void create_table_as(std::string const &tablename, SelectStmt const &stmt)
Definition: create_table.h:127
def key(type, name=None)
Definition: graph.py:13
void create_table(sqlite3 *const db, std::string const &tablename, Cols const &...cols)
Definition: create_table.h:118
Q_UINT16 values[128]
auto select(T const &...t)
Definition: select.h:146
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85