private void HandleNoSQLDBAction() { NoSqlBase.NoSqlBase NoSqlDriver = null; switch (this.DB.DBType) { case Database.eDBTypes.Cassandra: NoSqlDriver = new GingerCassandra(DBValidationType, DB, this); NoSqlDriver.PerformDBAction(); break; case Database.eDBTypes.Couchbase: NoSqlDriver = new GingerCouchbase(DBValidationType, DB, this); NoSqlDriver.PerformDBAction(); break; case Database.eDBTypes.MongoDb: NoSqlDriver = new GingerMongoDb(DBValidationType, DB, this); NoSqlDriver.PerformDBAction(); break; } }
public List <string> GetTablesList(string Keyspace = null) { List <string> rc = new List <string>() { "" }; if (MakeSureConnectionIsOpen()) { try { //if (oConn == null || oConn.State == ConnectionState.Closed) Connect(); if (DBType == Database.eDBTypes.Cassandra) { NoSqlBase.NoSqlBase NoSqlDriver = null; NoSqlDriver = new GingerCassandra(this); rc = NoSqlDriver.GetTableList(Keyspace); } else { DataTable table = oConn.GetSchema("Tables"); string tableName = ""; foreach (DataRow row in table.Rows) { switch (DBType) { case eDBTypes.MSSQL: tableName = (string)row[2]; break; case eDBTypes.Oracle: tableName = (string)row[1]; break; case eDBTypes.MSAccess: tableName = (string)row[2]; break; case eDBTypes.DB2: tableName = (string)row[2]; break; case eDBTypes.MySQL: tableName = (string)row[2]; break; } rc.Add(tableName); } } } catch (Exception e) { Reporter.ToLog(eLogLevel.ERROR, "Failed to get table list for DB:" + DBType.ToString(), e); throw (e); } } return(rc); }
public List <string> GetTablesColumns(string table) { DbDataReader reader = null; List <string> rc = new List <string>() { "" }; if ((oConn == null || string.IsNullOrEmpty(table)) && (DBType != Database.eDBTypes.Cassandra)) { return(rc); } if (DBType == Database.eDBTypes.Cassandra) { NoSqlBase.NoSqlBase NoSqlDriver = null; NoSqlDriver = new GingerCassandra(this); rc = NoSqlDriver.GetColumnList(table); } else if (DBType == Database.eDBTypes.Couchbase) { NoSqlBase.NoSqlBase NoSqlDriver = null; NoSqlDriver = new GingerCouchbase(this); rc = NoSqlDriver.GetColumnList(table); } else { try { DbCommand command = oConn.CreateCommand(); // Do select with zero records command.CommandText = "select * from " + table + " where 1 = 0"; command.CommandType = CommandType.Text; reader = command.ExecuteReader(); // Get the schema and read the cols DataTable schemaTable = reader.GetSchemaTable(); foreach (DataRow row in schemaTable.Rows) { string ColName = (string)row[0]; rc.Add(ColName); } } catch (Exception e) { Reporter.ToLog(eLogLevel.ERROR, "", e); //Reporter.ToUser(eUserMsgKey.DbTableError, "table columns", e.Message); throw (e); } finally { reader.Close(); } } return(rc); }
private void HandleNoSQLDBAction() { switch (this.DB.DBType) { case Database.eDBTypes.Cassandra: if (NoSqlDriver == null) { NoSqlDriver = new GingerCassandra(DBValidationType, DB, this); } else { if (NoSqlDriver.GetType() != typeof(GingerCassandra)) { NoSqlDriver = new GingerCassandra(DBValidationType, DB, this); } } break; case Database.eDBTypes.Couchbase: if (NoSqlDriver == null) { NoSqlDriver = new GingerCouchbase(DBValidationType, DB, this); } else { if (NoSqlDriver.GetType() != typeof(GingerCouchbase)) { NoSqlDriver = new GingerCouchbase(DBValidationType, DB, this); } } break; case Database.eDBTypes.MongoDb: if (NoSqlDriver == null) { NoSqlDriver = new GingerMongoDb(DBValidationType, DB, this); } else { if (NoSqlDriver.GetType() != typeof(GingerMongoDb)) { NoSqlDriver = new GingerMongoDb(DBValidationType, DB, this); } } break; } NoSqlDriver.MakeSureConnectionIsOpen(); NoSqlDriver.PerformDBAction(); }