SQLite database management tool
来源:互联网 发布:手机怎么恢复sd卡数据 编辑:程序博客网 时间:2024/06/06 03:22
The EAVCapture device needs to record its runtime log information. So for easy operation,
I choose the SQLite. It's suitable for the embedded device.
The default database file should be created automatically when the application starts at the first time.
I use the following sql statement to detect if the file is exist.
this->m_database=QSqlDatabase::addDatabase("QSQLITE");
this->m_database.setDatabaseName("EAV.db");
if(!this->m_database.open())
{
qDebug()<<"open sqlite database failed!";
return;
}
//create table.
QSqlQuery tSqlQuery(this->m_database);
if(!tSqlQuery.exec("SELECT COUNT(*) FROM devlog"))
{
//if select is failed,then create the table.
qDebug()<<"start to initial database";
if(!tSqlQuery.exec("CREATE TABLE devlog (CreateTime DATETIME,LogLevel INT,LogMessage BLOB)"))
{
qDebug()<<"create table failes!";
return;
}else{
qDebug()<<"create table success!";
}
}else{
qDebug()<<"database is already exists!";
}
If the file is exist,the sql statement "select count(*) from devlog" should return zero or positive value,
otherwise the exec() function will fails and return false. I can use its return value to know if it is exist.
by zhangshaoyan at May 24,2015 night.
And codes show how to insert a log message:
QString tCreateTime=QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss");
QString tSqlStatement=QString("INSERT INTO [devlog] ([CreateTime],[LogLevel],[LogMessage]) VALUES ('%1',%2,'%3')").arg(tCreateTime).arg(logLevel).arg(logMessage);
QSqlQuery tSqlQuery;
if(!tSqlQuery.exec(tSqlStatement))
{
return -1;
}
return 0;
- SQLite database management tool
- 现操week6 :File Management & SQLite Database
- WiFi GUI management tool
- Database Management Systems (Transaction Management)
- [SQLite]---database
- SQLite vs MySQL vs PostgreSQL: A Comparison Of Relational Database Management Systems
- Database management system
- Database Management Systems
- Liquibase --- Database Change Management
- Database Management Systems (Foundations)
- Database Management 整理
- Rally - Agile Project Management Tool
- macpro sqlite tool
- sqlite3: tool for sqlite
- Database Management Systems (Database Design and Tuning)
- EMS Database Management all software
- Database Management in PERL - DBI
- Database Writer and Buffer Management
- 分布式进阶(九)Ubuntu下使用nsenter进入Docker容器
- Swift中文教程(十八)类型转换
- 秒杀多线程第十六篇 多线程十大经典案例之一 双线程读写队列数据
- #笔记#圣思园 JavaSE 第55讲——泛型详解(2)
- Quartz 2D 请求上下文与强制重绘
- SQLite database management tool
- Swift中文教程(十九)类型嵌套
- 1003—IP聚合
- JAVA初始化(一)
- 监察、稽查、稽核与审计的关系
- 新站怎么样才能快速被收录?
- 分析问题要全面,不能够全面的分析为题时,有可能陷入误区
- Windows 驱动开发 - 3
- 天声人語 20150525