1、逐行读取文件;
2、对读取的每行字符串进行分割,以#为分隔符;
3、对分割后代每个qstring入库(sqllite)。
4 、简单代码实例:
void zzcsqllite::insertDataVehicle()
{
openDatabase();
QSqlQuery sql_query(database);
QFile file("Vehicle.txt");
if (file.open(QFile::ReadOnly | QIODevice::Text))
{
QTextStream in(&file);
QString strLine;
while (!in.atEnd())
{
strLine = in.readLine();
strLine.remove("\r\n");
QStringList sections = strLine.split(QRegExp( "[|#]"));
QString insert_sql = "insert into TF_OP_VEHICLE values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
sql_query.prepare(insert_sql);
sql_query.addBindValue(sections.at(0));
sql_query.addBindValue(sections.at(1));
sql_query.addBindValue(sections.at(2));
sql_query.addBindValu