目 录CONTENT

文章目录

C++ SQLITE_ORM 使用笔记(一)

WenzhouXv
2023-04-08 / 0 评论 / 0 点赞 / 42 阅读 / 0 字

SQLite_ORM 简单使用

配置VS2022

image-20230408072009122 image-20230408072053819 image-20230408072108907

创建数据库与表

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;
}
0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区