Skip to content

Instantly share code, notes, and snippets.

@dimiro1
Created February 13, 2014 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimiro1/8974953 to your computer and use it in GitHub Desktop.
Save dimiro1/8974953 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
import MySQLdb
import subprocess
my_host = "localhost"
my_user = "usuario"
my_pass = "senha"
my_db = "banco"
command_restart_mysql = "service mysql restart"
try:
db = MySQLdb.connect(host=my_host, user=my_user, passwd=my_pass, db=my_db)
except MySQLdb.Error, e:
subprocess.check_output(command_restart_mysql, shell=True)
print "Error %d: %s" % (e.args[0], e.args[1])
sys.exit (1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment