Created by Frederik Banke 2018-01-30 View revision File snippet.BUILD Added Side-by-side diff More Ignore whitespace Hide word diff +import mysql.connector + + +def get_data_from_mysql(cnx, key): + cursor = cnx.cursor(prepared=True) + + query = "SELECT field FROM items WHERE key = %s" + + cursor.execute(query, (key,)) + + total = 0 + for row in cursor: + total += row[0] + + cursor.close() + + return total