1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
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