comparison sat/memory/sqlite.py @ 2735:ba74914277cf

core (memory/sqlite): new delPrivateNamespace method to delete all data of a specific namespace for a profile.
author Goffi <goffi@goffi.org>
date Wed, 02 Jan 2019 18:25:55 +0100
parents 14e1db0c1383
children 1e2f0856c845
comparison
equal deleted inserted replaced
2734:9702025f6dff 2735:ba74914277cf
715 args.append(self.profiles[profile]) 715 args.append(self.profiles[profile])
716 d = self.dbpool.runQuery(u" ".join(query_parts), args) 716 d = self.dbpool.runQuery(u" ".join(query_parts), args)
717 d.addErrback(self._privateDataEb, u"delete", namespace, key, profile=profile) 717 d.addErrback(self._privateDataEb, u"delete", namespace, key, profile=profile)
718 return d 718 return d
719 719
720 def delPrivateNamespace(self, namespace, binary=False, profile=None):
721 """Delete all data from a private namespace
722
723 Be really cautious when you use this method, as all data with given namespace are
724 removed.
725 Params are the same as for delPrivateValue
726 """
727 table = self._getPrivateTable(binary, profile)
728 query_parts = [u"DELETE FROM", table, u"WHERE namespace=?"]
729 args = [namespace]
730 if profile is not None:
731 query_parts.append(u"AND profile_id=?")
732 args.append(self.profiles[profile])
733 d = self.dbpool.runQuery(u" ".join(query_parts), args)
734 d.addErrback(self._privateDataEb, u"delete namespace", namespace, profile=profile)
735 return d
736
720 ## Files 737 ## Files
721 738
722 @defer.inlineCallbacks 739 @defer.inlineCallbacks
723 def getFiles(self, client, file_id=None, version=u'', parent=None, type_=None, 740 def getFiles(self, client, file_id=None, version=u'', parent=None, type_=None,
724 file_hash=None, hash_algo=None, name=None, namespace=None, mime_type=None, 741 file_hash=None, hash_algo=None, name=None, namespace=None, mime_type=None,