35 lines
901 B
C++
35 lines
901 B
C++
#include <iostream>
|
|
|
|
#include "database.h"
|
|
#include "table.h"
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
DataBase base("test1");
|
|
DataBase::Table<uint32_t, uint32_t>* table1 = base.addTable<uint32_t, uint32_t>("table1");
|
|
DataBase::Table<QString, QString>* table2 = base.addTable<QString, QString>("table2");
|
|
|
|
base.open();
|
|
|
|
try {
|
|
table1->addRecord(1, 2);
|
|
} catch (const DataBase::Exist& error) {
|
|
std::cout << error.getMessage() << std::endl;
|
|
}
|
|
|
|
uint32_t rec1 = table1->getRecord(1);
|
|
std::cout << "table1 record under 1 is " << rec1 << std::endl;
|
|
|
|
try {
|
|
table2->addRecord("hello", "world");
|
|
} catch (const DataBase::Exist& error) {
|
|
std::cout << error.getMessage() << std::endl;
|
|
}
|
|
|
|
QString rec2 = table2->getRecord("hello");
|
|
std::cout << "table2 record under hello is " << rec2.toStdString() << std::endl;
|
|
|
|
return 0;
|
|
}
|