Title: lookup func Author: waterapple Pastebin link: http://pastebin.com/R2DvbzJC First Edit: Saturday 14th of March 2015 11:11:42 PM CDT Last Edit: Last edit on: Saturday 14th of March 2015 11:44:20 PM CDT def lookup_field(connection,table,field,value):     """Return a list of all rows matching the given table/field/value group     If no rows match, return None     ONLY set field through code, NEVER give field from outside data"""     logging.debug("checking table: "+table+" for feild: "+repr(field)+" and value: "+repr(value))     cursor =  connection.cursor()     # Check for existing records for the file hash     check_query = "SELECT * FROM `%s` WHERE %s = '%s';"     logging.debug(check_query)     cursor.execute(check_query, (table,field,value))     media_already_saved = False     check_row_counter = 0     rows = []     for row in cursor:         check_row_counter += 1         logging.debug("row: "+repr(row))         rows.append(row)     logging.debug("rows: "+repr(rows))     cursor.close()     if len(rows) > 0:         return rows     else:         return None