def init(self): SQLiteDB.init(self) cursor = None try: cursor = self.connection.cursor() self.create_table(cursor, PUBLISHED_CONTENTS) self.create_table(cursor, PUBLISHED_CELLS) self.create_table(cursor, SNAPSHOTS) self.create_table(cursor, DEP_TABLES) self.create_table(cursor, DELTAS) # To avoid multiple usernames in the login table, use always "login" as id cursor.execute("create table if not exists login (id TEXT UNIQUE, " "username TEXT UNIQUE, token TEXT)") cursor.execute("create table if not exists %s " "(reference TEXT UNIQUE, cell_id TEXT, content_id TEXT)" % PUBLISHED_REFERENCES) cursor.execute("CREATE INDEX if not exists cell_id_index ON %s (cell_id)" % (PUBLISHED_REFERENCES)) cursor.execute("CREATE INDEX if not exists content_id_index ON %s (content_id)" % (PUBLISHED_REFERENCES)) except Exception as e: message = "Could not initalize local cache" raise ClientException(message, e) finally: if cursor: cursor.close()
def init(self, last_client_migration): try: SQLiteDB.init(self) statement = self.connection.cursor() self.create_table(statement, CONTENTS) self.create_table(statement, VERSION) # Last migrated version is last migration available self.upsert_last_migrated(last_client_migration) except Exception as e: raise ClientException("Could not initalize local cache", e)