|
@@ -16,13 +16,13 @@ class MysqlWrapper(replwrap.REPLWrapper):
|
|
|
replwrap.REPLWrapper.__init__(self, cmd_or_spawn, orig_prompt,
|
|
|
prompt_change, extra_init_cmd=extra_init_cmd)
|
|
|
|
|
|
- def _expect_prompt(self, timeout=-1):
|
|
|
+ def _expect_prompts(self, timeout=-1):
|
|
|
if timeout == None:
|
|
|
while True:
|
|
|
pos = self.child.expect_exact([self.prompt, self.continuation_prompt, u'\r\n'],
|
|
|
timeout=None)
|
|
|
if pos == 2:
|
|
|
- self.line_output_callback(self.child.before + '\n')
|
|
|
+ self.line_output_callback(self.child.before)
|
|
|
else:
|
|
|
if len(self.child.before) != 0:
|
|
|
self.line_output_callback(self.child.before)
|
|
@@ -40,7 +40,9 @@ if __name__ == '__main__':
|
|
|
password = '123456'
|
|
|
child = pexpect.spawn('mysql -u%s -h%s -P%s -p%s' % (user, ip, port,password))
|
|
|
py = MysqlWrapper(child, u"mysql>", None,extra_init_cmd=None,line_output_callback=output)
|
|
|
- py.run_command("show databases;", timeout=None)
|
|
|
+
|
|
|
+ outout = py.run_command("use dever;select * from plant_forum_posts;", timeout=None)
|
|
|
+ print py.child.before
|
|
|
"""
|
|
|
child = pexpect.spawn('mysql -u%s -h%s -P%s -p' % (user, ip, port))
|
|
|
child.expect ('password:')
|