comparison src/memory/memory.py @ 853:c2f6ada7858f

core (sqlite): automatic database update: - new Updater class check database consistency (by calculating a hash on the .schema), and updates base if necessary - database now has a version (1 for current, 0 will be for 0.3's database), for each change this version will be increased - creation statements and update statements are in the form of dict of dict with tuples. There is a help text at the top of the module to explain how it works - if we are on a development version, the updater try to update the database automaticaly (without deleting table or columns). The Updater.generateUpdateData method can be used to ease the creation of update data (i.e. the dictionary at the top, see the one for the key 1 for an example). - if there is an inconsistency, an exception is raised, and a message indicate the SQL statements that should fix the situation. - well... this is rather complicated, a KISS method would maybe have been better. The future will say if we need to simplify it :-/ - new DatabaseError exception
author Goffi <goffi@goffi.org>
date Sun, 23 Feb 2014 23:30:32 +0100
parents f3513c8cc2e6
children f27d736428f1
comparison
equal deleted inserted replaced
852:4cc55e05266d 853:c2f6ada7858f
780 # /!\ an entity is not necessarily in roster 780 # /!\ an entity is not necessarily in roster
781 self.subscriptions = {} 781 self.subscriptions = {}
782 self.server_features = {} # used to store discovery's informations 782 self.server_features = {} # used to store discovery's informations
783 self.server_identities = {} 783 self.server_identities = {}
784 self.config = self.parseMainConf() 784 self.config = self.parseMainConf()
785 host.set_const('savefile_database', SAVEFILE_DATABASE) 785 host.setConst('savefile_database', SAVEFILE_DATABASE)
786 database_file = os.path.expanduser(self.getConfig('', 'local_dir') + 786 database_file = os.path.expanduser(self.getConfig('', 'local_dir') +
787 self.host.get_const('savefile_database')) 787 self.host.getConst('savefile_database'))
788 self.storage = SqliteStorage(database_file) 788 self.storage = SqliteStorage(database_file, host.__version__)
789 PersistentDict.storage = self.storage 789 PersistentDict.storage = self.storage
790 self.params = Params(host, self.storage) 790 self.params = Params(host, self.storage)
791 info(_("Loading default params template")) 791 info(_("Loading default params template"))
792 self.params.load_default_params() 792 self.params.load_default_params()
793 d = self.storage.initialized.addCallback(lambda ignore: self.load()) 793 d = self.storage.initialized.addCallback(lambda ignore: self.load())