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


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

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


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

示例1: dbExistsTable

SEXP dbExistsTable(SEXP dbi_conn_sexp, SEXP tableName_sexp) {
  SEXP ans;

 if(TYPEOF(dbi_conn_sexp) != EXTPTRSXP || dbi_conn_sexp == R_NilValue) {
    return R_NilValue;
  }

  DatabaseConnection* conn = reinterpret_cast<DatabaseConnection*>(R_ExternalPtrAddr(dbi_conn_sexp));
  if(!conn) {
    // throw bad_connection_object
    REprintf("bad database connection.\n");
    return R_NilValue;
  }

  const char* tableName = CHAR(STRING_ELT(tableName_sexp,0));
  PROTECT(ans = allocVector(LGLSXP,1));
  LOGICAL(ans)[0] = static_cast<int>(conn->existsTable(tableName));
  UNPROTECT(1);
  return ans;
}
开发者ID:armstrtw,项目名称:unifieddbi,代码行数:20,代码来源:interface.cpp

示例2: dbWriteTable

// return number of rows written to database
// using both overwrite and append is a bad design decision
// there should just be overwrite, which will drop the table if it exists
// append should be automatic if the table exists, and should fail if the row formats don't match up
// having both overwrite and append just complicates the logic of this function
SEXP dbWriteTable(SEXP dbi_conn_sexp, SEXP tableName_sexp, SEXP value_sexp, SEXP writeRowNames_sexp, SEXP overWrite_sexp, SEXP append_sexp) {
  SEXP ans;
  int rows;

 if(TYPEOF(dbi_conn_sexp) != EXTPTRSXP || dbi_conn_sexp == R_NilValue) {
    return R_NilValue;
  }

  DatabaseConnection* conn = reinterpret_cast<DatabaseConnection*>(R_ExternalPtrAddr(dbi_conn_sexp));
  if(!conn) {
    // throw bad_connection_object
    REprintf("bad database connection.\n");
    return ScalarInteger(0);
  }
  if(TYPEOF(tableName_sexp) != STRSXP) {
    REprintf("ERROR: tableName is not a string.\n");
    return ScalarInteger(0);
  }
  const char* tableName = CHAR(STRING_ELT(tableName_sexp,0));
  const bool writeRowNames = static_cast<bool>(LOGICAL(writeRowNames_sexp)[0]);
  const bool overWrite = static_cast<bool>(LOGICAL(overWrite_sexp)[0]);

  if(conn->existsTable(tableName) && overWrite) {
    if(!conn->removeTable(tableName)) {
      REprintf("could not remove existing table (aborting).\n");
      return ScalarInteger(0);
    }
  }

  try {
    rows = conn->writeTable(tableName, value_sexp, writeRowNames);
  } catch (MapToTypeNotImplemented& e) {
    REprintf("%s\n",e.what());
    return R_NilValue;
  }
  PROTECT(ans = allocVector(INTSXP,1));
  INTEGER(ans)[0] = rows;
  UNPROTECT(1);
  return ans;
}
开发者ID:armstrtw,项目名称:unifieddbi,代码行数:45,代码来源:interface.cpp


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