Ejemplo n.º 1
0
def _connect(state):

    # Open DB connection
    state.db_conn = db_iface.db_open(state.model.filepath)
    if state.db_conn:
        pass
        '''
        _D.DEBUG(
                __name__,
                "File Versioned Tracking DB found on disk",
                'filepath', state.model.filepath,
                'db_conn', state.db_conn
                )
        '''
    else:
        state.db_conn = db_iface.db_create(state.model.filepath)
        '''
        _D.DEBUG(
                __name__,
                "File Versioned Tracking DB not found on disk, creating new",
                'filepath', state.model.filepath,
                'db_conn', state.db_conn
                )
        '''

        c = state.db_conn.cursor()
        sql = "CREATE TABLE versions \
                ( \
                id INTEGER PRIMARY KEY, \
                date INTEGER UNIQUE, \
                file TEXT, \
                size INTEGER \
                )"
        c.execute(sql)
        state.db_conn.commit()
Ejemplo n.º 2
0
def _connect(state):

    # Open DB connection
    state.db_conn = db_iface.db_open(state.model.filepath)
    if state.db_conn:
        pass
        '''
        _D.DEBUG(
                __name__,
                "DB Stats found on disk",
                'filepath', state.model.filepath,
                'db_conn', state.db_conn
                )
        '''
    else:
        state.db_conn = db_iface.db_create(state.model.filepath)
        '''
        _D.WARNING(
                __name__,
                "DB Stats not found on disk, creating new",
                'filepath', state.model.filepath,
                'db_conn', state.db_conn
                )
        '''

        c = state.db_conn.cursor()
        sql = "CREATE TABLE sessions_store \
                ( \
                id INTEGER PRIMARY KEY, \
                date INTEGER, \
                backup_type TEXT, \
                size INTEGER \
                )"
        c.execute(sql)
        state.db_conn.commit()
Ejemplo n.º 3
0
def _connect(state):

    # Open DB connection
    state.db_conn = db_iface.db_open(state.model.filepath)
    if state.db_conn:
        pass
        '''
        _D.DEBUG(
                __name__,
                "File Incremental Tracking DB found on disk",
                'filepath', state.model.filepath,
                'db_conn', state.db_conn
                )
        '''
    else:
        state.db_conn = db_iface.db_create(state.model.filepath)
        '''
        _D.DEBUG(
                __name__,
                "File Incremental Tracking DB not found on disk, creating new",
                'filepath', state.model.filepath,
                'db_conn', state.db_conn
                )
        '''

        c = state.db_conn.cursor()

        # Table files: list of files in storage
        sql = "CREATE TABLE files_storage \
                ( \
                name TEXT UNIQUE, \
                modified INTEGER, \
                size INTEGER \
                )"
        c.execute(sql)

        # Table files_local: list of files found on local disk
        sql = "CREATE TABLE files_local \
                ( \
                name TEXT UNIQUE, \
                modified INTEGER, \
                size INTEGER \
                )"
        c.execute(sql)

        # Table files_upload: list of files to be stored
        sql = "CREATE TABLE files_upload \
                ( \
                name TEXT UNIQUE, \
                modified INTEGER, \
                size INTEGER \
                )"
        c.execute(sql)

        # Table stats: stored amount of data by date
        sql = "CREATE TABLE stats \
                ( \
                date TEXT, \
                size INTEGER \
                )"
        c.execute(sql)

        # Table params: about this backup
        sql = "CREATE TABLE params \
                ( \
                id INTEGER PRIMARY KEY, \
                dir_local TEXT, \
                url_storage TEXT \
                )"
        c.execute(sql)

        state.db_conn.commit()