def init(self): try: self.schema = self.getSchema() try: self.checkTables() except DbTableError: pass self.log.debug("Checking foreign keys...") foreign_key_error = self.execute( "PRAGMA foreign_key_check").fetchone() if foreign_key_error: raise Exception("Database foreign key error: %s" % foreign_key_error) except Exception as err: self.log.error("Error loading content.db: %s, rebuilding..." % Debug.formatException(err)) self.close() os.unlink(self.db_path) # Remove and try again Db.__init__(self, { "db_name": "ContentDb", "tables": {} }, self.db_path) self.foreign_keys = True self.schema = self.getSchema() try: self.checkTables() except DbTableError: pass self.site_ids = {} self.sites = {}
def __init__(self, path): Db.__init__(self, {"db_name": "ContentDb", "tables": {}}, path) self.foreign_keys = True
def openDb(self, close_idle=False): schema = self.getDbSchema() db_path = self.getPath(schema["db_file"]) return Db(schema, db_path, close_idle=close_idle)