MCPcopy Create free account
hub / github.com/SOCI/soci / main

Function main

examples/subdir-include/subdir-include.cpp:9–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7#include <string>
8
9int main(int argc, char* argv[])
10{
11 if (argc != 2)
12 {
13 std::cerr << "usage: " << argv[0] << " <connection-string>\n";
14 return EXIT_FAILURE;
15 }
16
17 std::string connectString{argv[1]};
18
19 try
20 {
21 soci::session sql(soci::empty, connectString);
22
23 std::cout << "Successfully connected to \"" << connectString << "\", "
24 << "using \"" << sql.get_backend_name() << "\" backend.\n";
25
26 return EXIT_SUCCESS;
27 }
28 catch (const soci::soci_error& e)
29 {
30 std::cerr << "Connection to \"" << connectString << "\" failed: "
31 << e.what() << "\n";
32 }
33 catch (const std::runtime_error& e)
34 {
35 std::cerr << "Unexpected standard exception occurred: "
36 << e.what() << "\n";
37 }
38 catch (...)
39 {
40 std::cerr << "Unexpected unknown exception occurred.\n";
41 }
42
43 return EXIT_FAILURE;
44}

Callers

nothing calls this directly

Calls 2

get_backend_nameMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected