惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

Sonui – 魔帆博客

【记录】使用Golang开发腾讯云函数踩的坑 | 魔帆博客 【笔记】Hydro二次开发总结 前端篇(一) | 魔帆博客 C/C++ 二叉树 | 魔帆博客 Linux 报错Certificate verification failed: The certificate is NOT trusted. | 魔帆博客 Python 数字大小写转换 | 魔帆博客 Windows10 系统盘开启 Bitlocker | 魔帆博客 【源码】打猎游戏 html 纯原生代码 | 魔帆博客 VS Code C/C++ 环境配置 | 魔帆博客 【技巧】干掉第三方抢票!如何以最快的速度抢到火车票 | 魔帆博客 【记录】Deepin 桌面无限转圈(风火轮) | 魔帆博客 【软件】QQ坦白说发送者查看 --已凉 | 魔帆博客 手把手教你重装原版纯净Windows系统-魔帆出品 | 魔帆博客 【软件】XML文本解析器 | 魔帆博客 【软件】Mac OS环境下最强虚拟机软件--Parallels Desktop | 魔帆博客 【镜像】Mac OS X El Capitan 10.11 (15B42) 懒人版安装镜像 支持变色龙和Clvoer引导 | 魔帆博客 【技术向】如何获取指定QQ在线状态 | 魔帆博客 QQ广告屏蔽器 | 魔帆博客 【开源】自己写的机器人插件源码部分开源 | 魔帆博客 5月20号真的是潘金莲毒死武大郎的日子么?? | 魔帆博客
easySQLite使用帮助 | 魔帆博客
Sonui · 2019-02-09 · via Sonui – 魔帆博客

项目地址:https://code.google.com/archive/p/easysqlite/

由于需要用到sqlite,经过一番兜兜转转,看到了easySQL,下载下来,还不错,就是有些地方说明不够详细,以此做补充

打开数据库

db.open(fileName);

使用时提示 “Database::open: unable to open database file”,可能是因为fileName编码不正确,因为此处要求ut8编码,尝试在前头加上 u8,例如:

db.open(u8″D:/中文文件夹名/test.db”);

或对fileName进行转码

//gbk转UTF-8
string GbkToUtf8(const std::string& strGbk)//传入的strGbk是GBK编码
{
	//gbk转unicode
	int len = MultiByteToWideChar(CP_ACP, 0, strGbk.c_str(), -1, NULL, 0);
	wchar_t *strUnicode = new wchar_t[len];
	wmemset(strUnicode, 0, len);
	MultiByteToWideChar(CP_ACP, 0, strGbk.c_str(), -1, strUnicode, len);
	//unicode转UTF-8
	len = WideCharToMultiByte(CP_UTF8, 0, strUnicode, -1, NULL, 0, NULL, NULL);
	char * strUtf8 = new char[len];
	WideCharToMultiByte(CP_UTF8, 0, strUnicode, -1, strUtf8, len, NULL, NULL);
	std::string strTemp(strUtf8);//此时的strTemp是UTF-8编码
	delete[]strUnicode;
	delete[]strUtf8;
	strUnicode = NULL;
	strUtf8 = NULL;
	return strTemp;
}

取字段值

    //load all records
    tbPerson.open();

    //list loaded records
    for (int index = 0; index < tbPerson.recordCount(); index++){
        if (Record* record = tbPerson.getRecord(index)) {
            Value* value = record->getValue("value");  //取value字段的值
            Value* value2 = record->getKeyIdValue();  //取主键ID
        }
    }