core (memory/sqlite): new delPrivateNamespace method to delete all data of a specific namespace for a profile.

This commit is contained in:
Goffi 2019-01-02 18:25:55 +01:00
commit 6e38be1dab

View file

@ -717,6 +717,23 @@ class SqliteStorage(object):
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