qt sqlite用事务加速写数据库

速度能有几十倍的提升
示例:

bool TelephoneDb::InsertAllAddress(std::map<QString, TelephoneAddress> & addresses)
{
    db_.transaction();//事务
    QString sql;
    for(std::map<QString,TelephoneAddress>::iterator it = addresses.begin();it != addresses.end();++it){
        sql = "insert into address values ('" + it->second.id + "','" + it->second.number + "','" + it->second.name + "')";
        if(!query_.exec(sql)){
            SqlError();
        }
    }
    db_.commit();
    return true;
}

你可能感兴趣的:(QT,qt,sqlite用事务加速写数据库,qt,sqlite事务,sqlite事务)