import mysql.connector def getConnector(): return mysql.connector.connect( host="localhost", user="root", ) def getCursor(connector): return connector.cursor() def runQuery(connector, query): cursor = getCursor(connector) cursor.execute(query) result = cursor.fetchall() cursor.close() return result