QSqlDatabase db_sqlite = QSqlDatabase::addDatabase(“QSQLITE”, “connSQLite”);
db_sqlite.setDatabaseName(“SQLiteDB.db3”);
db_sqlite.open();
QSqlQuery query("", db_sqlite);
bool bsuccess = false;
QTime tmpTime;
// 开始启动事务
db_sqlite.transaction();
tmpTime.start();
for(int i = 0; i<100000; i++)
{
bsuccess = query.exec(“insert into DataBase(D_1,D_2,D_3,D_4,D_5) values(‘TT’,‘TT’,‘TT’,‘TT’,‘TT’)”);
if (!bsuccess)
{
cout<<“Error occur”<<endl;
break;
}
}
// 提交事务,这个时候才是真正打开文件执行SQL语句的时候
db_sqlite.commit();