DROPping users in Python
Dropping a user in Python is as easy as passing the MySQL statement through Cursor.execute()
. So the syntax is:
DROP USER exemplar@localhost;
This previous syntax can be changed to:
mydb = MySQLdb.connect(host = 'localhost', user = 'root', passwd = 'rootsecret') cursor = mydb.cursor() statement = """DROP USER exemplar@localhost""" cursor.execute(statement)
However, any part of the statement can be dynamically created through the use of string formatting conventions.