import MySQLdb from MySQLdb.connections import Connection class LibraryOperation: def build_query(self): return '' def print_error(self, cur): rows = cur.fetchall() for row in rows: if 'error_description' in row: print (row['error_description']) def execute(self, db : Connection): cur = db.cursor() query = self.build_query() print(query) cur.execute(query) self.print_error(cur)