/
auroraos
/
mirror_sqlite3pp
Обзор
Документация
Войти
/
auroraos
/
mirror_sqlite3pp
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
master
test/testselect.cpp
53 строки
1 KB
Wongoo Lee
Merge pull request #13 from paxos1977/EliminateUnusedParametersWarnings
18 июн 2015, 23:12
18 июн 2015, 23:12
1683480
Код
Авторство
О чём код?
#include <string> #include <iostream> #include "sqlite3pp.h" using namespace std; int main() { try { sqlite3pp::database db("test.db"); sqlite3pp::transaction xct(db, true); { sqlite3pp::query qry(db, "SELECT id, name, phone FROM contacts"); for (int i = 0; i < qry.column_count(); ++i) { cout << qry.column_name(i) << "\t"; } cout << endl; for (sqlite3pp::query::iterator i = qry.begin(); i != qry.end(); ++i) { for (int j = 0; j < qry.column_count(); ++j) { cout << (*i).get<char const*>(j) << "\t"; } cout << endl; } cout << endl; qry.reset(); for (sqlite3pp::query::iterator i = qry.begin(); i != qry.end(); ++i) { int id; char const* name, *phone; std::tie(id, name, phone) = (*i).get_columns<int, char const*, char const*>(0, 1, 2); cout << id << "\t" << name << "\t" << phone << endl; } cout << endl; qry.reset(); for (sqlite3pp::query::iterator i = qry.begin(); i != qry.end(); ++i) { int id = 0; std::string name, phone; (*i).getter() >> sqlite3pp::ignore >> name >> phone; cout << id << "\t" << name << "\t" << phone << endl; } } } catch (exception& ex) { cout << ex.what() << endl; } }