def find_by_template(self, template, field_list=None, limit=None, offset=None, order_by=None, commit=True): """ :param template: A dictionary of the form { "field1" : value1, "field2": value2, ...} :param field_list: A list of request fields of the form, ['fielda', 'fieldb', ...] :param limit: Do not worry about this for now. :param offset: Do not worry about this for now. :param order_by: Do not worry about this for now. :return: A list containing dictionaries. A dictionary is in the list representing each record that matches the template. The dictionary only contains the requested fields. """ result = None try: sql, args = dbutils.create_select(self._full_table_name, template=template, fields=field_list) res, data = dbutils.run_q(sql=sql, args=args, conn=self._cnx, commit=True, fetch=True) except Exception as e: print("Exception e = ", e) raise e return list(data)
def delete_by_template(self, template): """ Deletes all records that match the template. :param template: A template. :return: A count of the rows deleted. """ try: sql, args = dbutils.create_select(self._full_table_name, template=template, is_select=False) res, d = dbutils.run_q(sql, args=args, conn=self._cnx, commit=True) return res except Exception as e: print("Got exception e = ", e) raise e