I would like to make sure that the user has mysql installed in order to run a script. Normally I would type in $ mysql in the shell and if it goes to the mysql> prompt I know I'm good. However, how would I do this from within a python script? Something like:
try:
    assert (0 == subprocess.call("mysql -u root -e 'show databases'", shell=True, stderr=subprocess.DEVNULL))
except AssertionError:
    print ("You need to install mysql to run this script")\
What would be the proper way to do this?
 
    