Created
March 12, 2018 04:50
-
-
Save imranbhullar/3363a91cd4fdc2e58bc15c532310c101 to your computer and use it in GitHub Desktop.
Using pexpect to play with mysql.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pexpect | |
child = pexpect.spawn ('mysql -umyuser -pmysupersecret -hxxx.xxx.xxx.xxx') | |
child.expect ('mysql> ') | |
child.sendline ('show databases;\n') | |
child.expect ('mysql> ') | |
print child.before | |
child.expect('mysql> ') | |
child.sendline ('show processlist;') | |
child.expect ('mysql> ') | |
print child.before | |
child.sendline ('quit') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment