diff options
Diffstat (limited to 'template/driver.cxx')
-rw-r--r-- | template/driver.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/template/driver.cxx b/template/driver.cxx new file mode 100644 index 0000000..e9dab52 --- /dev/null +++ b/template/driver.cxx @@ -0,0 +1,39 @@ +// file : hello/driver.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : not copyrighted - public domain + +#include <memory> // std::auto_ptr +#include <iostream> + +#include <odb/database.hxx> +#include <odb/transaction.hxx> + +#include "database.hxx" // create_database + +#include "person.hxx" +#include "person-odb.hxx" + +using namespace std; +using namespace odb; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr<database> db (create_database (argc, argv)); + + { + person p ("John", "Doe", 21); + + transaction t (db->begin_transaction ()); + db->persist (p); + t.commit (); + } + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} |