SQLite_ORM 简单使用
配置VS2022
创建数据库与表
struct AGZoomView {
int id;
int view_type;
double view_margin;
};
{
//创建数据库,创建表
auto storage = make_storage("E:/AUGS/data/blob.db",
make_table("ag_zoome_view",
make_column("id", &AGZoomView::id, primary_key()),
make_column("view_type", &AGZoomView::view_type),
make_column("view_margin", &AGZoomView::view_margin)));
storage.sync_schema();
storage.remove_all<AGZoomView>();
};
初始化值
{
AGZoomView alex{
0,
0,
5.5
};
}
插入数据
{
alex.id = storage.insert(alex);
}
更改数据
{
alex.view_margin = 11.1;
storage.update(alex);
}
读取数据
{
auto employee = storage.get<AGZoomView>(1);
std::cout << employee.view_margin << std::endl;
}
评论区