pick up orphan test
[sqlgg.git] / test_pqxx / test_pqxx.cpp
blob917f74e5dda6e3d0f6e4293649cda1abda025edd
1 #include <iostream>
2 #include <pqxx/pqxx>
3 #include "pqxx_traits.hpp"
4 #include "test_gen.hpp"
6 using namespace std;
7 using namespace pqxx;
9 typedef sqlgg<pqxx_traits> gen;
11 int main()
13 try
15 connection C("dbname=test");
16 cout << "Connected to " << C.dbname() << endl;
17 work W(C);
19 result R;
20 R = W.exec("DROP TABLE employee");
21 gen::create_employee(W);
23 gen::insert_employee(W,"john",2);
24 gen::insert_employee(W,"jack",3);
25 gen::insert_employee(W,"bob",4);
26 R = W.exec("SELECT name FROM employee");
28 cout << "Found " << R.size() << " employees:" << endl;
29 for (result::const_iterator r = R.begin();
30 r != R.end();
31 ++r)
33 cout << r[0].c_str() << endl;
36 cout << "Doubling all employees' salaries..." << endl;
37 W.exec("UPDATE employee SET salary=salary*2");
39 cout << "Making changes definite: ";
40 W.commit();
41 cout << "ok." << endl;
43 catch (const exception &e)
45 cerr << e.what() << endl;
46 return 1;
48 return 0;