public MySqlViewList(MySqlCommand cmd) { try { string dbname = QueryExpress.ExecuteScalarStr(cmd, "SELECT DATABASE();"); _sqlShowViewList = string.Format("SHOW FULL TABLES FROM `{0}` WHERE Table_type = 'VIEW';", dbname); DataTable dt = QueryExpress.GetTable(cmd, _sqlShowViewList); foreach (DataRow dr in dt.Rows) { var nome = dr[0].ToString(); _lst.Add(nome, new MySqlView(cmd, nome)); } } catch (MySqlException myEx) { if (myEx.Message.ToLower().Contains("access denied")) { _allowAccess = false; } } catch { throw; } }
public MySqlProcedureList(MySqlCommand cmd) { try { string dbname = QueryExpress.ExecuteScalarStr(cmd, "SELECT DATABASE();"); _sqlShowProcedures = string.Format("SHOW PROCEDURE STATUS WHERE UPPER(TRIM(Db))= UPPER(TRIM('{0}'));", dbname); DataTable dt = QueryExpress.GetTable(cmd, _sqlShowProcedures); foreach (DataRow dr in dt.Rows) { var name = dr["Name"].ToString(); _lst.Add(name, new MySqlProcedure(cmd, name, dr["Definer"].ToString())); } } catch (MySqlException myEx) { if (myEx.Message.ToLower().Contains("access denied")) { _allowAccess = false; } } catch { throw; } }
public MySqlTriggerList(MySqlCommand cmd) { _sqlShowTriggers = "SHOW TRIGGERS;"; try { DataTable dt = QueryExpress.GetTable(cmd, _sqlShowTriggers); foreach (DataRow dr in dt.Rows) { var name = dr["Trigger"].ToString(); _lst.Add(name, new MySqlTrigger(cmd, name, dr["Definer"].ToString())); } } catch (MySqlException myEx) { if (myEx.Message.ToLower().Contains("access denied")) { _allowAccess = false; } } catch { throw; } }
public MySqlColumnList(MySqlCommand cmd, string tableName) { _tableName = tableName; DataTable dtDataType = QueryExpress.GetTable(cmd, string.Format("SELECT * FROM `{0}` where 1 = 2;", tableName)); _sqlShowFullColumns = string.Format("SHOW FULL COLUMNS FROM `{0}`;", tableName); DataTable dtColInfo = QueryExpress.GetTable(cmd, _sqlShowFullColumns); for (int i = 0; i < dtDataType.Columns.Count; i++) { string isNullStr = (dtColInfo.Rows[i]["Null"] + "").ToLower(); bool isNull = false; if (isNullStr == "yes") { isNull = true; } var name = dtDataType.Columns[i].ColumnName; _lst.Add( name, new MySqlColumn( name, dtDataType.Columns[i].DataType, dtColInfo.Rows[i]["Type"] + "", dtColInfo.Rows[i]["Collation"] + "", isNull, dtColInfo.Rows[i]["Key"] + "", dtColInfo.Rows[i]["Default"] + "", dtColInfo.Rows[i]["Extra"] + "", dtColInfo.Rows[i]["Privileges"] + "", dtColInfo.Rows[i]["Comment"] + "") ); } }
public MySqlTableList(MySqlCommand cmd) { _sqlShowFullTables = "SHOW FULL TABLES WHERE Table_type = 'BASE TABLE';"; DataTable dtTableList = QueryExpress.GetTable(cmd, _sqlShowFullTables); foreach (DataRow dr in dtTableList.Rows) { var table = new MySqlTable(cmd, dr[0] + ""); _lst.Add(table.Name, table); } }
public void GetTotalRows(MySqlCommand cmd, GetTotalRowsMethod enumGetTotalRowsMode) { int i = 0; var timer = new Timer { Interval = 10000 }; timer.Elapsed += (sender, e) => { GetTotalRowsProgressChanged?.Invoke(this, new GetTotalRowsArgs(_listTable.Count, i)); }; if (enumGetTotalRowsMode == GetTotalRowsMethod.InformationSchema) { DataTable dtTotalRows = QueryExpress.GetTable(cmd, string.Format("SELECT TABLE_NAME, TABLE_ROWS FROM `information_schema`.`tables` WHERE `table_schema` = '{0}';", _name)); timer.Start(); foreach (DataRow dr in dtTotalRows.Rows) { i++; var _tbname = dr["TABLE_NAME"] + ""; long.TryParse(dr["TABLE_ROWS"] + "", out var _totalRowsThisTable); if (_listTable.Contains(_tbname)) { _listTable[_tbname].SetTotalRows((long)(_totalRowsThisTable * 1.1)); // Adiciona 10% de erro } } timer.Stop(); GetTotalRowsProgressChanged?.Invoke(this, new GetTotalRowsArgs(_listTable.Count, _listTable.Count)); } else if (enumGetTotalRowsMode == GetTotalRowsMethod.SelectCount) { timer.Start(); foreach (var table in _listTable) { i++; table.GetTotalRowsByCounting(cmd); } timer.Stop(); GetTotalRowsProgressChanged?.Invoke(this, new GetTotalRowsArgs(_listTable.Count, _listTable.Count)); } }