Example #1
0
def upgrade(filename):
    ver = dbv.detectVersion(filename)
    conn = sqlite3.connect(filename, detect_types=sqlite3.PARSE_DECLTYPES)
    conn.row_factory = sqlite3.Row  #Make cursors return row objects instead of tuples.
    c = conn.cursor()
    print "Upgrading database from version " + str(ver) + " to version " + str(
        ver + 1)
    if ver == 1:
        if (DEBUG):
            print "Changing memref::proc from type text to type addr\n\tCreating TEMP_TABLE"
        c.execute(
            "CREATE TABLE TEMP_TABLE (addr address, proc address, type text)")
        if (DEBUG):
            print "\tTransferring values from memref to TEMP_TABLE"
        c.execute("INSERT INTO TEMP_TABLE SELECT * FROM memref")
        if (DEBUG):
            print "\tDropping memref"
        c.execute("DROP TABLE memref")
        if (DEBUG):
            print "\tRenaming TEMP_TABLE to memref"
        c.execute("ALTER TABLE TEMP_TABLE RENAME TO memref")
    else:
        c.close()
        conn.close()
        raise ValueError("Don't know about version " + str(ver + 1) + " yet!")
    c.close()
    conn.commit()
    conn.close()
Example #2
0
def upgrade(filename):
    ver=dbv.detectVersion(filename)
    conn = sqlite3.connect(filename, detect_types=sqlite3.PARSE_DECLTYPES)
    conn.row_factory = sqlite3.Row  #Make cursors return row objects instead of tuples.
    c=conn.cursor()
    print "Upgrading database from version "+str(ver)+" to version "+str(ver+1)
    if ver==1:
        if (DEBUG):
            print "Changing memref::proc from type text to type addr\n\tCreating TEMP_TABLE"
        c.execute("CREATE TABLE TEMP_TABLE (addr address, proc address, type text)")
        if (DEBUG):
            print "\tTransferring values from memref to TEMP_TABLE"
        c.execute("INSERT INTO TEMP_TABLE SELECT * FROM memref")
        if (DEBUG):
            print "\tDropping memref"
        c.execute("DROP TABLE memref")
        if (DEBUG):
            print "\tRenaming TEMP_TABLE to memref"
        c.execute("ALTER TABLE TEMP_TABLE RENAME TO memref")
    else:
        c.close()
        conn.close()
        raise ValueError("Don't know about version "+str(ver+1)+" yet!")
    c.close()
    conn.commit()
    conn.close()
Example #3
0
def doUpgrade(name):
    filename = getDB(name)
    ver = dbv.detectVersion(filename)
    if ver == 0:
        print "Unknown database version!"
        print "Skipping upgrade check."
        return
    print "Database is version", ver
    print "Latest version is", LATEST_VERSION
    if ver != LATEST_VERSION:
        shutil.copy(filename, filename + ".ver" + str(ver) + ".bak")
        upgradeDatabase(filename)
        print "Done!"
    else:
        print "Nothing to do!"
Example #4
0
def doUpgrade(name):
    filename=getDB(name)
    ver=dbv.detectVersion(filename)
    if ver==0:
        print "Unknown database version!"
        print "Skipping upgrade check."
        return
    print "Database is version",ver
    print "Latest version is",LATEST_VERSION
    if ver!=LATEST_VERSION:
        shutil.copy(filename,filename+".ver"+str(ver)+".bak")
        upgradeDatabase(filename)
        print "Done!"
    else:
        print "Nothing to do!"
Example #5
0
def upgradeDatabase(name):
    ver = dbv.detectVersion(name)
    for i in xrange(LATEST_VERSION - ver):
        dbu.upgrade(name)
Example #6
0
def upgradeDatabase(name):
    ver=dbv.detectVersion(name)
    for i in xrange(LATEST_VERSION-ver):
        dbu.upgrade(name)