# HG changeset patch # User Goffi # Date 1546449955 -3600 # Node ID ba74914277cf3f165c12c2d19ba723c8fb543043 # Parent 9702025f6dfff617b1ed46d0201dd7f4f8579e73 core (memory/sqlite): new delPrivateNamespace method to delete all data of a specific namespace for a profile. diff -r 9702025f6dff -r ba74914277cf sat/memory/sqlite.py --- a/sat/memory/sqlite.py Wed Jan 02 18:24:14 2019 +0100 +++ b/sat/memory/sqlite.py Wed Jan 02 18:25:55 2019 +0100 @@ -717,6 +717,23 @@ d.addErrback(self._privateDataEb, u"delete", namespace, key, profile=profile) return d + def delPrivateNamespace(self, namespace, binary=False, profile=None): + """Delete all data from a private namespace + + Be really cautious when you use this method, as all data with given namespace are + removed. + Params are the same as for delPrivateValue + """ + table = self._getPrivateTable(binary, profile) + query_parts = [u"DELETE FROM", table, u"WHERE namespace=?"] + args = [namespace] + if profile is not None: + query_parts.append(u"AND profile_id=?") + args.append(self.profiles[profile]) + d = self.dbpool.runQuery(u" ".join(query_parts), args) + d.addErrback(self._privateDataEb, u"delete namespace", namespace, profile=profile) + return d + ## Files @defer.inlineCallbacks