Samchon Framework for CPP  1.0.0
sql.hpp
1 #pragma once
2 
3 #include <iostream>
4 #include <samchon/library/TSQLi.hpp>
5 
6 using namespace std;
7 using namespace samchon::library;
8 
9 namespace samchon
10 {
11 namespace examples
12 {
13 namespace sql
14 {
15  void main()
16  {
17  using namespace std;
18  using namespace samchon::library;
19 
20  shared_ptr<SQLi> sqli(new TSQLi());
21 
22  try
23  {
24  sqli->connect("211.239.161.211", "REDPRINTING_TEST", "redprinting_test", "redprinting");
25 
26  auto stmt = sqli->createStatement();
27  size_t uid = 5;
28  wstring name = L"°í±æµ¿";
29  wstring department = L"È«º¸ºÎ; stmt->prepare(L"INSERT INTO ÇѱÛÅ×À̺í (¹øÈ£, À̸§, ºÎ¼­) VALUES (?, ?, ?)", uid, name, department); stmt->execute(); stmt->executeDirectly(u8"SELECT * FROM ÇѱÛÅ×À̺í"); while (stmt->fetch()) { int uid = stmt->at<int>(0); const string &name = stmt->at<string>(1); const string &department = stmt->at<string>(2); cout << uid << endl; cout << name << endl; cout << department << endl; } } catch (exception &e) { cout << e.what() << endl; } }; } } }";
30 
31  stmt->prepare(L"INSERT INTO ÇѱÛÅ×À̺í (¹øÈ£, À̸§, ºÎ¼­) VALUES (?, ?, ?)", uid, name, department);
32  stmt->execute();
33 
34  stmt->executeDirectly(u8"SELECT * FROM ÇѱÛÅ×À̺í); while (stmt->fetch()) { int uid = stmt->at<int>(0); const string &name = stmt->at<string>(1); const string &department = stmt->at<string>(2); cout << uid << endl; cout << name << endl; cout << department << endl; } } catch (exception &e) { cout << e.what() << endl; } }; } } }");
35 
36  while (stmt->fetch())
37  {
38  int uid = stmt->at<int>(0);
39  const string &name = stmt->at<string>(1);
40  const string &department = stmt->at<string>(2);
41 
42  cout << uid << endl;
43  cout << name << endl;
44  cout << department << endl;
45  }
46  }
47  catch (exception &e)
48  {
49  cout << e.what() << endl;
50  }
51  };
52 }
53 }
54 }
A SQL interface for T-SQL.
Definition: TSQLi.hpp:19