bool Project::openDatabase( const QString &connection, bool suppressDialog ) { #ifndef QT_NO_SQL DatabaseConnection *conn = databaseConnection( connection ); if ( connection.isEmpty() && !conn ) conn = databaseConnection( "(default)" ); if ( !conn ) return FALSE; bool b = conn->open( suppressDialog ); return b; #else Q_UNUSED( connection ); Q_UNUSED( suppressDialog ); return FALSE; #endif }
void do_speed_test() { string const filename("aaksjh237nsal"); int const loops = 50000; vector<string> statements; statements.push_back ( "insert into dummy(colA, colB) values(3, 'hi')" ); statements.push_back ( "select colA, colB from dummy where colB = " " 'asfkjasdlfkasdfasdf' and colB = '-90982097';" ); statements.push_back ( "insert into dummy(colA, colB) values(198712319, 'aasdfhasdkjhash');" ); statements.push_back ( "select colA, colB from dummy where colA = " " 'noasdsjhasdfkjhasdkfjh' and colB = '-9987293879';" ); vector<string>::size_type const num_statements = statements.size(); string const table_creation_string ( "create table dummy(colA int not null, colB text)" ); // With SQLStatement DatabaseConnection db; db.open(filename); db.execute_sql(table_creation_string); cout << "Timing with SQLStatement." << endl; db.execute_sql("begin"); Stopwatch sw1; for (int i = 0; i != loops; ++i) { SQLStatement s(db, statements[i % num_statements]); // s.step_final(); } sw1.log(); db.execute_sql("end"); windows_friendly_remove(filename); // With SQLStatementImpl SQLiteDBConn sdbc; sdbc.open(filename); sdbc.execute_sql(table_creation_string); cout << "Timing with SQLStatementImpl." << endl; sdbc.execute_sql("begin"); Stopwatch sw0; for (int i = 0; i != loops; ++i) { SQLStatementImpl s(sdbc, statements[i % num_statements]); // s.step_final(); } sw0.log(); sdbc.execute_sql("end"); windows_friendly_remove(filename); return; }