示例#1
0
    def delete_by_template(self, template):
        """

        :param template: Template to determine rows to delete.
        :return: Number of rows deleted.
        """
        cox = pymysql.connect(**self.connect_info)
        sql, args = SQLHelper.create_delete(table_name=self.table_name,
                                            template=template)
        num, res = SQLHelper.run_q(sql, args, cox)
        return num
    def delete_by_template(self, template):
        """

        :param template: Template to determine rows to delete.
        :return: Number of rows deleted.
        """
        sql, args = SQLHelper.create_delete(table_name=self.table_name,
                                            template=template)
        res, data = SQLHelper.run_q(sql=sql,
                                    args=args,
                                    conn=self.connect_info,
                                    commit=self.commit)
        return res
示例#3
0
    def delete_by_key(self, key_fields):
        """

        Deletes the record that matches the key.

        :param template: A template.
        :return: A count of the rows deleted.
        """
        cox = pymysql.connect(**self.connect_info)
        template = dict(zip(self.key_columns, key_fields))
        sql, args = SQLHelper.create_delete(self.table_name, template)
        num, res = SQLHelper.run_q(sql, args, cox)
        return num
    def delete_by_key(self, key_fields):
        """

        Deletes the record that matches the key.

        :param template: A template.
        :return: A count of the rows deleted.
        """
        template = {k: v for k, v in zip(self.key_columns, key_fields)}
        sql, args = SQLHelper.create_delete(table_name=self.table_name,
                                            template=template)
        res, data = SQLHelper.run_q(sql=sql,
                                    args=args,
                                    conn=self.connect_info,
                                    commit=self.commit)
        return res