def get(): try: dbcon = database.connect(ctrl.cacheFile) dbcur = dbcon.cursor() dbcur.execute("SELECT ver, install_date FROM %s ORDER BY ver DESC LIMIT 1" % (table)) return dbcur.fetchone() except: ctrl.log('Error getting the cache version value.')
def set(version): try: t = int(time.time()) dbcon = database.connect(ctrl.cacheFile) dbcur = dbcon.cursor() dbcur.execute("INSERT INTO %s Values (?, ?)" % table, (version, t)) dbcon.commit() except: ctrl.log('Error setting the version in the cache.')
def init(): ctrl.log('Initializing Cache...') try: if not ctrl.exists(ctrl.dataPath + '/'): ctrl.log('Creating cache.db file') ctrl.makeFile(ctrl.dataPath) dbcon = database.connect(ctrl.cacheFile) dbcur = dbcon.cursor() t = int(time.time()) dbcur.execute("CREATE TABLE IF NOT EXISTS %s (""ver INTEGER"", ""install_date TEXT "");" % table) dbcur.execute("DELETE FROM %s" % (table)) dbcur.execute("INSERT INTO %s Values (?, ?)" % table, ('0', t)) dbcon.commit() except: ctrl.log('Error initializing the cache.db')