#include <QtSql>
#include <iostream>
bool Test_Qt_Sqlite()
{
QSqlDatabase dbConn = QSqlDatabase::addDatabase("QSQLITE");
std::string strDatabaseName("sqlite.db");
dbConn.setDatabaseName(strDatabaseName.c_str());
if(!dbConn.open())
{
std::cout << "db not opened" << std::endl;
}
QSqlQuery queryTest;
std::string strCreateTable("create table student(id varchar, name varchar)");
queryTest.exec(strCreateTable.c_str());
std::string strInsert("intert into student values(1, '狗仔')");
return false;
}
////////////////
qsqlquery似乎不需要指定connection,莫非全部在底层搞了,这样如果需要多个sql connection怎么办,,,还是看源码吧,qt确实很多东东不到位啊