예제 #1
0
파일: localdb.py 프로젝트: toeb/client
    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()
예제 #2
0
    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)
예제 #3
0
파일: hivedb.py 프로젝트: biicode/client
    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)