tquser / training

1 stars 0 forks source link

Automate ayrlive database creation #2

Open tquser opened 6 years ago

tquser commented 6 years ago

public static void RestoreDatabaseUsingMysqlDump(string strPath) { string strComment = "--host={0} --user={1} --password={2} ";

        string strCommandArgs = string.Format(strComment, Settings.Default.ServerAddressStore, Settings.Default.ServerUserId, Settings.Default.ServerPassword, Settings.Default.StoreDB, strPath);
        Process myProcess = new Process();
        myProcess.StartInfo.FileName = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "Utils", "mysql.exe");
        myProcess.StartInfo.UseShellExecute = false;
        myProcess.StartInfo.CreateNoWindow = true;
        myProcess.StartInfo.Arguments = strCommandArgs;//"-uroot -ptouchq --databases movedb --result-file=" + "\"" + path + "\"";
        myProcess.StartInfo.RedirectStandardInput = true;
        myProcess.StartInfo.RedirectStandardOutput = false;

        myProcess.Start();
        using (var stdin = myProcess.StandardInput)
        using (var reader = File.OpenText(strPath))
        {
            string line;
            while ((line = reader.ReadLine()) != null)
            {
                stdin.WriteLine(line);
            }

            stdin.Close();
        }
        myProcess.WaitForExit();
        myProcess.Close();
    }
ebineby commented 6 years ago

The above code is in c# console application . Which can be used to dumb (make) the data base in My SQL work bench as a SQL file. When the console.exe will be executed The database will be created at mysql work bench.The above Console.exe file will be called from the innosetup.

rajeshpr commented 6 years ago

1)Please install all my sql components manually. 2)Extend your console application using above code to create database