当前位置: 首页>>代码示例>>C++>>正文


C++ DatabaseConnection::execute_sql方法代码示例

本文整理汇总了C++中DatabaseConnection::execute_sql方法的典型用法代码示例。如果您正苦于以下问题:C++ DatabaseConnection::execute_sql方法的具体用法?C++ DatabaseConnection::execute_sql怎么用?C++ DatabaseConnection::execute_sql使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DatabaseConnection的用法示例。


在下文中一共展示了DatabaseConnection::execute_sql方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: filename

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;
}
开发者ID:matt-harvey,项目名称:sqloxx,代码行数:66,代码来源:sqloxx_tests_common.cpp


注:本文中的DatabaseConnection::execute_sql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。