示例#1
0
 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 = {}
示例#2
0
 def __init__(self, path):
     Db.__init__(self, {"db_name": "ContentDb", "tables": {}}, path)
     self.foreign_keys = True
示例#3
0
 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)