我正在尝试从Linux机器中获取数据库,并使用WinSCP .NET程序集使用以下代码执行此操作:
SessionOptions sessionSettings = new SessionOptions
{
Protocol = Protocol.Scp,
HostName = "******",
UserName = "*****",
Password = "*****",
SshHostKeyFingerprint = "****************************"
};
using (Session session = new Session())
{
session.Open(sessionSettings);
TransferOperationResult ibData = session.GetFiles("/var/lib/mysql/ibdata1", @"Documents\Visual Studio 2015\Projects\Project1\Project1\Database\ibdata1.myd");
ibData.Check();
TransferOperationResult ib_logfile0 = session.GetFiles("/var/lib/mysql/ib_logfile0", @"Documents\Visual Studio 2015\Project1\Project1\Database\ib_logfile0");
ib_logfile0.Check();
TransferOperationResult ib_logfile1 = session.GetFiles("/var/lib/mysql/ib_logfile1", @"Documents\Visual Studio 2015\Projects\Project1\Project1\Database\ib_logfile1");
ib_logfile1.Check();
TransferOperationResult mysql = session.GetFiles("/var/lib/mysql/mysql", @"Documents\Visual Studio 2015\Project1\Project1\Database\mysql");
mysql.Check();
TransferOperationResult oreka = session.GetFiles("/var/lib/mysql/oreka", @"Documents\Visual Studio 2015\Projects\Project1\Project1\Database\oreka");
oreka.Check();
TransferOperationResult test = session.GetFiles("/var/lib/mysql/test", @"Documents\Visual Studio 2015\Projects\Project1\Project1\Database\test");
test.Check();
}
既然我有/var/lib/mysql
的数据库,我不知道如何提取我需要继续的数据。我该怎么做呢?
答案 0 :(得分:0)
你的问题很难说清楚。
但我想您想使用mysqldump
command将数据库转储到文件中,然后下载转储。
您可以使用Session.ExecuteCommand
method来呼叫def error_check_in_thread(self, method):
self.connect(method, QtCore.SIGNAL("selenium_error"), lambda: self.error_launch("selenium_error"))
self.connect(method, QtCore.SIGNAL("attribute_error"), lambda: self.error_launch("attribute_error"))
self.connect(method, QtCore.SIGNAL("name_error"), lambda: self.error_launch("name_error"))
self.connect(method, QtCore.SIGNAL("os_error"), lambda: self.error_launch("os_error"))
self.connect(method, QtCore.SIGNAL("finished()"), lambda: self.append_log(0))
self.connect(method, QtCore.SIGNAL("terminated()"), lambda: self.append_log(1))
method.start()
return
def error_launch(self, error):
dialog = ErrorDialogs()
if error == "selenium_error":
dialog.pipeline_pilot_automation_error()
elif error == "attribute_error":
dialog.attribute_error()
elif error == "os_error":
dialog.path_error()
elif error == "session_info_error":
dialog.session_info_error()
self.error_counter += 1
return
def append_log(self, exit_type):
if exit_type == 0:
self.log_edit_area.appendPlainText(str(MainGui.log_output[0]))
elif exit_type == 1:
self.log_edit_area.appendPlainText("THE METHOD WAS TERMINATED PREMATURELY\n" + "#"*50)
MainGui.log_output = []
class WorkingThread(QtCore.QThread):
def __init__(self, selector):
QtCore.QThread.__init__(self)
self.selector = selector
self.method_info = None
def __del__(self):
self.wait()
# Controls which function to launch in another thread based on button presses in MainGui
def run(self):
print("start")
try:
if self.selector == 1:
self.method_info = "DIRECTORIES AND SUBDIRECTORIES CREATION "
MainGui.log_output.append("ACTION AT: " + "[[" + str(datetime.datetime.now()) + "]]" + "\n" +
self.method_info + "SUCCESSFUL FOR: " + MainGui.da_batch_name + "\n" + "#"*50)
asa.mkdirsda(MainGui.hdg_da_path, MainGui.da_batch_folder, MainGui.da_batch_subfolders)
elif self.selector == 2:
self.method_info = "LIMS SAMPLE SHEET MOVEMENT TO AUTOSCORE SUBDIRECTORY "
MainGui.log_output.append("ACTION AT: " + "[[" + str(datetime.datetime.now()) + "]]" + "\n" +
self.method_info + "SUCCESSFUL FOR: " + MainGui.da_batch_name + "\n" + "#"*50)
asa.mvlims(MainGui.needs_gs_lims_file, MainGui.subfolder_autoscore,
MainGui.lims_samplesheet)
elif self.selector == 3:
self.method_info = "GENOMESTUDIO "
MainGui.log_output.append("ACTION AT: " + "[[" + str(datetime.datetime.now()) + "]]" + "\n" +
self.method_info + "STARTED FOR: " + MainGui.da_batch_name + "\n" + "#"*50)
asa.gsprocess(MainGui.subfolder_genomestudio, MainGui.da_batch_name,
MainGui.lims_samplesheet_file)
MainGui.log_output.append("ACTION AT: " + "[[" + str(datetime.datetime.now()) + "]]" + "\n" +
self.method_info + "SUCCESSFUL FOR: " + MainGui.da_batch_name + "\n" + "#"*50)
elif self.selector == 4:
self.method_info = "FINAL REPORT MOVEMENT TO AUTOSCORE SUBDIRECTORY "
MainGui.log_output.append("ACTION AT: " + "[[" + str(datetime.datetime.now()) + "]]" + "\n" +
self.method_info + "SUCCESSFUL FOR: " + MainGui.da_batch_name + "\n" + "#"*50)
asa.mvfinalreport(MainGui.subfolder_genomestudio, MainGui.da_batch_name,
MainGui.finalreport_file, MainGui.subfolder_autoscore)
elif self.selector == 5:
self.method_info = "PIPELINE PILOT AUTOMATION "
MainGui.log_output.append("ACTION AT: " + "[[" + str(datetime.datetime.now()) + "]]" + "\n" +
self.method_info + "STARTED FOR: " + MainGui.da_batch_name + "\n" + "#"*50)
asa.pipelineas(MainGui.userid, MainGui.userpass, MainGui.da_batch_name,
MainGui.raw_data_path)
MainGui.log_output.append("ACTION AT: " + "[[" + str(datetime.datetime.now()) + "]]" + "\n" +
self.method_info + "SUCCESSFUL FOR: " + MainGui.da_batch_name + "\n" + "#"*50)
elif self.selector == 6:
self.method_info = "GBS SET DIRECTORIES CREATION"
MainGui.log_output.append("ACTION AT: " + "[[" + str(datetime.datetime.now()) + "]]" + "\n" +
self.method_info + "SUCCESSFUL FOR: " + MainGui.gbs_set_name + "\n" + "#"*50)
asa.mkdirsgbs(MainGui.gbs_path, MainGui.gbs_set_name)
except (ElementNotVisibleException, ElementNotSelectableException, NoSuchElementException,
NoSuchWindowException, UnexpectedAlertPresentException):
MainGui.log_output.append("ACTION AT: " + "[[" + str(datetime.datetime.now()) + "]]" + "\n" +
self.method_info + "FAILED DUE TO SELENIUM ERROR\n" + "#"*50)
selenium_error = QtCore.pyqtSignal()
self.emit(QtCore.SIGNAL("selenium_error"))
return
except AttributeError:
MainGui.log_output.append("ACTION AT: " + "[[" + str(datetime.datetime.now()) + "]]" + "\n" +
self.method_info + "FAILED DUE TO ATTRIBUTE ERROR\n" + "#"*50)
attribute_error = QtCore.pyqtSignal()
self.emit(QtCore.SIGNAL("attribute_error"))
print("stop")
return
return
。但是你显然需要对服务器进行shell访问才能做到这一点。