void setupDiskDb()
{
db.setDatabaseName("CatchyName");
db.open();
query.exec("CREATE TABLE T1(F1, F2, F3)");
}
void doSqLiteTest2()
{
db.setDatabaseName(":memory:");
db.open();
query.exec("CREATE TABLE T1(F1, F2, F3)");
query.prepare("INSERT INTO T1 (F1, F2, F3) "
"VALUES (:1, :2, :3)");
for (int i = 0; i < 50000; i++)
{
query.bindValue(":1", i + 0);
query.bindValue(":2", i + 1);
query.bindValue(":3", i + 2);
query.exec();
}
qDebug() << query.exec("ATTACH DATABASE 'CatchyName' AS Catchy");
qDebug() << query.exec("INSERT INTO Catchy.T1(F1, F2, F3) SELECT F1, F2, F3 FROM T1");
}
int main(int argc, char * argv[])
{
setupDiskDb();
doSqLiteTest2();
return a.exec();
}
void setupDiskDb()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "disk");
db.setDatabaseName("CatchyName");
db.open();
QSqlQuery query(db);
query.exec("CREATE TABLE T1(F1, F2, F3)");
}
void doSqLiteTest2()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "mem");
db.setDatabaseName(":memory:");
db.open();
QSqlQuery query(db);
query.exec("CREATE TABLE T1(F1, F2, F3)");
query.prepare("INSERT INTO T1 (F1, F2, F3) "
"VALUES (:1, :2, :3)");
for (int i = 0; i < 50000; i++)
{
query.bindValue(":1", i + 0);
query.bindValue(":2", i + 1);
query.bindValue(":3", i + 2);
query.exec();
}
qDebug() << query.exec("ATTACH DATABASE 'CatchyName' AS Catchy");
qDebug() << query.exec("INSERT INTO Catchy.T1(F1, F2, F3) SELECT F1, F2, F3 FROM T1");
}
int main(int argc, char * argv[])
{
QApplication a(argc, argv);
setupDiskDb();
doSqLiteTest2();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks