public void dropTable(MysqlHandler connection, string tableName, bool backup) { bool disconnecting = false; if (!connection.isConnected()) { disconnecting = true; connection.connect(); } if (backup) { dropTable(connection, tableName + "_backup", false); copyTable(connection, tableName, tableName + "_backup"); } string sql = "DROP TABLE " + tableName; connection.sql_update(sql); if (disconnecting) { connection.disConnect(); } }
public string getMysqlDump(MysqlHandler connection, string sourceTable) { bool disconnecting = false; if (!connection.isConnected()) { disconnecting = true; connection.connect(); } string ResultStr = connection.getTableCreationString(sourceTable); ResultStr += "\n\n"; List <string> SqlArr = getSqlDumpRows(connection, sourceTable); for (int i = 0; i < SqlArr.Count; i++) { ResultStr += SqlArr[i]; } if (disconnecting) { connection.disConnect(); } return(ResultStr); }
public bool copyCreationTable(MysqlHandler connection, string sourceTable, MysqlHandler targetConnection) { bool disconnecting = false; bool targetDisconnecting = false; if (!connection.isConnected()) { disconnecting = true; connection.connect(); } if (!targetConnection.isConnected()) { targetDisconnecting = true; targetConnection.connect(); } string createSql = connection.getTableCreationString(sourceTable); if (createSql != "") { targetConnection.sql_update(createSql); } if (disconnecting) { connection.disConnect(); } if (targetDisconnecting) { targetConnection.disConnect(); } targetConnection.resetTableList(); return(targetConnection.tableExists(sourceTable)); }
public List <String> getCopyTableStatements(MysqlHandler connection, string sourceTable, MysqlHandler targetConnection) { bool disconnecting = false; bool targetDisconnecting = false; List <String> querys = new List <string>(); if (!connection.isConnected()) { disconnecting = true; connection.connect(); } if (!targetConnection.isConnected()) { targetDisconnecting = true; targetConnection.connect(); } targetConnection.lastSqlErrorMessage = ""; querys.Add("DROP TABLE IF EXISTS " + sourceTable); querys.Add(connection.getTableCreationString(sourceTable)); copyRowLimit = 500; Int64 writes = 0; Int64 start = 0; writes = getCopyStatements(connection, sourceTable, start, targetConnection, querys, useMassInsertQuerys); start = writes; while (writes != 0) { if (showProgress) { msg.msg.Text = "Block ...." + start + " @ " + sourceTable; msg.Refresh(); } writes = getCopyStatements(connection, sourceTable, start, targetConnection, querys, useMassInsertQuerys); start += writes; } copyRowLimit = 10000; if (disconnecting) { connection.disConnect(); } if (targetDisconnecting) { targetConnection.disConnect(); } return(querys); }
private void button1_Click(object sender, EventArgs e) { if (lastSelectedId != "") { MysqlHandler mysql = new MysqlHandler(watchProfil); mysql.connect(); string sql = "KILL " + lastSelectedId; mysql.sql_update(sql); mysql.disConnect(); kill_btn.Text = "KILL "; } }
public void copyTable(MysqlHandler connection, string sourceTable, MysqlHandler targetConnection) { bool disconnecting = false; bool targetDisconnecting = false; if (!connection.isConnected()) { disconnecting = true; connection.connect(); } if (!targetConnection.isConnected()) { targetDisconnecting = true; targetConnection.connect(); } targetConnection.lastSqlErrorMessage = ""; if (!targetConnection.tableExists(sourceTable)) { string createSql = connection.getTableCreationString(sourceTable); targetConnection.sql_update(createSql); if (targetConnection.lastSqlErrorMessage.Length > 0) { MessageBox.Show(createSql + "\n\n" + targetConnection.lastSqlErrorMessage); targetConnection.lastSqlErrorMessage = ""; } else { copyRows(connection, sourceTable, targetConnection); } } if (disconnecting) { connection.disConnect(); } if (targetDisconnecting) { targetConnection.disConnect(); } targetConnection.resetTableList(); }
public void copyTable(MysqlHandler connection, string sourceTable, string targetTable) { bool disconnecting = false; string sql = "CREATE TABLE " + targetTable + " SELECT * FROM " + sourceTable; if (!connection.isConnected()) { disconnecting = true; connection.connect(); } connection.sql_update(sql); if (disconnecting) { connection.disConnect(); } }
private void mysql_watcher_DoWork(object sender, DoWorkEventArgs e) { ListView retObj = (ListView)e.Argument; //ListView retObj = new ListView(); MysqlHandler mysql = new MysqlHandler(watchProfil); mysql.connect(); string sql = "show full processlist"; MySql.Data.MySqlClient.MySqlDataReader rankings = mysql.sql_select(sql); if (retObj != null) { mysql.sql_data2ListView(rankings, retObj); } mysql.disConnect(); }
public String alterTableFromSource(MysqlHandler connection, string sourceTable, MysqlHandler targetConnection, Boolean addOnly) { bool disconnecting = false; bool targetDisconnecting = false; if (!connection.isConnected()) { disconnecting = true; connection.connect(); } if (!targetConnection.isConnected()) { targetDisconnecting = true; targetConnection.connect(); } string createSql = connection.getTableCreationString(sourceTable); List <MysqlStruct> sourceStruct = connection.getAllFieldsStruct(sourceTable); List <MysqlStruct> targetStruct = targetConnection.getAllFieldsStruct(sourceTable); String alterSql = getAlterTableSql(sourceStruct, targetStruct, addOnly); if (alterSql.Length > 0) { alterSql = "ALTER TABLE `" + sourceTable + "` " + alterSql; } if (disconnecting) { connection.disConnect(); } if (targetDisconnecting) { targetConnection.disConnect(); } targetConnection.resetTableList(); return(alterSql); }
private void checkConnection(Profil testProfil) { MysqlHandler TestConnect = new MysqlHandler(testProfil); try { TestConnect.connect(); } catch (Exception) { //throw; } if (TestConnect.lastSqlErrorMessage.Length > 0) { errorLabel.Text = TestConnect.lastSqlErrorMessage; } else { errorLabel.Text = Projector.Properties.Resources.MysqlConnectionTestSucces; TestConnect.disConnect(); } }
public static statusResult checkConnection(Profil testProfil) { statusResult result = new statusResult(); MysqlHandler TestConnect = new MysqlHandler(testProfil); TestConnect.connect(); if (TestConnect.lastSqlErrorMessage.Length > 0) { result.message = TestConnect.lastSqlErrorMessage; result.status = false; result.StatusKey = 0; return(result); } else { TestConnect.disConnect(); result.message = Projector.Properties.Resources.MysqlConnectionTestSucces;; result.status = true; result.StatusKey = 1; return(result); } }
private void MysqlSensor_FormClosing(object sender, FormClosingEventArgs e) { database.disConnect(); }