SqlDumpImportProcess
::SqlDumpImportProcess() : QProcess(){
}
void SqlDumpImportProcess
::importFile(QString file_name,
QString database_name
) {
setStandardInputFile(file_name);
connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(slot_read_std_out()));
QString process_command
("mysql -u tempuser --verbose --password=temppassword --force ");
process_command.append(database_name);
start(process_command);
waitForFinished(-1); // -1 means don't time out
}
void SqlDumpImportProcess::slot_read_std_out()
{
printEntry;
out_string.simplified();
int create_index = out_string.indexOf("CREATE TABLE", 0, Qt::CaseInsensitive);
if (create_index >= 0)
{
QString insert_substring
= out_string.
mid(create_index
);
QString table_name
= insert_substring.
section(" ",
2,
2);
// 0 = "CREATE", 1 = "TABLE", 2 = table name table_name.remove("`");
emit signal_create_table(table_name);
}
}
SqlDumpImportProcess::SqlDumpImportProcess() : QProcess()
{
}
void SqlDumpImportProcess::importFile(QString file_name, QString database_name)
{
setStandardInputFile(file_name);
connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(slot_read_std_out()));
QString process_command("mysql -u tempuser --verbose --password=temppassword --force ");
process_command.append(database_name);
start(process_command);
waitForFinished(-1); // -1 means don't time out
}
void SqlDumpImportProcess::slot_read_std_out()
{
printEntry;
QByteArray byte_array = readAllStandardOutput();
QString out_string(byte_array);
out_string.simplified();
int create_index = out_string.indexOf("CREATE TABLE", 0, Qt::CaseInsensitive);
if (create_index >= 0)
{
QString insert_substring = out_string.mid(create_index);
QString table_name = insert_substring.section(" ", 2, 2); // 0 = "CREATE", 1 = "TABLE", 2 = table name
table_name.remove("`");
emit signal_create_table(table_name);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks