· 6 years ago · Jul 28, 2019, 06:32 AM
1.vcpkg.exe install sqlite-modern-cpp:x64-uwp
2
3.vcpkg.exe install sqlite3:x64-uwp
4
5.vcpkg.exe integrate install
6
7#include "sqlite_modern_cpp.h"
8
9#include "sqlite3.h"
10
11void MainPage::ClickHandler(IInspectable const&, RoutedEventArgs const&)
12{
13 myButton().Content(box_value(L"Clicked"));
14
15 // path for the temporary database file
16 hstring path{ ApplicationData::Current().LocalFolder().Path() + L"\temp.db" };
17
18 // store the file name for use later
19 std::string fname = to_string(path.c_str());
20
21 // open a connection to the database or create the file if it doesn't exist
22 sqlite::database db(fname); // default is READWRITE | CREATE
23
24 // enable foreign keys
25 db << "PRAGMA foreign_keys = ON;";
26
27 // create a new table, if needed
28 db << "CREATE TABLE IF NOT EXISTS division ("
29 " id INTEGER PRIMARY KEY AUTOINCREMENT,"
30 " name TEXT NOT NULL,"
31 " distance INTEGER NOT NULL,"
32 " size INTEGER NOT NULL,"
33 " lanes INTEGER NOT NULL,"
34 " rank INTEGER NOT NULL,"
35 " progression TEXT NOT NULL,"
36 " UNIQUE (name, distance, size)"
37 ");";
38}