Example #1
0
    Connection::Connection(const char* conninfo)
      : transactionActive(0)
    {
      log_debug("sqlite3_open(\"" << conninfo << "\")");
      int errcode = ::sqlite3_open(conninfo, &db);

      if (db == 0)
        throw Execerror("sqlite3_open", db, errcode);

      log_debug("sqlite3 = " << db);

      log_debug("sqlite3_busy_timeout(\"" << db << "\", 60000)");
      errcode = ::sqlite3_busy_timeout(db, 60000);
      if (errcode != SQLITE_OK)
        throw Execerror("sqlite3_busy_timeout", db, errcode);
    }
Example #2
0
    Row Cursor::fetch()
    {
      log_debug("sqlite3_step(" << stmt << ')');
      int ret = ::sqlite3_step(stmt);
      if (ret == SQLITE_DONE)
        return Row();
      else if (ret != SQLITE_ROW)
        throw Execerror("sqlite3_step", stmt, ret);

      return Row(new StmtRow(getStmt()));
    }
Example #3
0
    Connection::size_type Connection::execute(const std::string& query)
    {
      char* errmsg;

      log_debug("sqlite3_exec(" << db << ", \"" << query << "\", 0, 0, " << &errmsg << ')');

      int ret = ::sqlite3_exec(db, query.c_str(), 0, 0, &errmsg);

      log_debug("sqlite3_exec ret=" << ret);

      if (ret != SQLITE_OK)
        throw Execerror("sqlite3_exec", ret, errmsg, true);

      return ::sqlite3_changes(db);
    }