Exemple #1
0
class dbs:
    '''Google Citation DB
	DB Operations of this task is all here.
	'''

    # constants
    genkey = "arnet.update.generation"

    def __init__(self):
        self.constantsDao = ConstantsDAO()

    #######################################################
    # ConstantDao - Mainly do some thing with constants.
    #
    #	ConstantsDB Structure:
    #		id, name, value, time
    #
    # Keys in ConstantsDB:
    #	 arnet.update.generation
    #
    #######################################################
    def getGeneration(self):
        return int(self.constantsDao.getConstant(self.genkey))

    def setGeneration(self, newGeneration):
        while True:
            try:
                conn = DB.pool().getConnection()
                cursor = conn.cursor()
                cursor.execute("update constants set value=%s where name=%s",
                               (newGeneration, self.genkey))
                cursor.close()
                conn.close()
                return cursor.rowcount
            except MySQLdb.Error, e:
                print "Error %d: %s" % (e.args[0], e.args[1])
Exemple #2
0
class dbs:
    """Google Citation DB
	DB Operations of this task is all here.
	"""

    # constants
    genkey = "arnet.update.generation"

    def __init__(self):
        self.constantsDao = ConstantsDAO()

        #######################################################
        # ConstantDao - Mainly do some thing with constants.
        #
        # 	ConstantsDB Structure:
        # 		id, name, value, time
        #
        # Keys in ConstantsDB:
        # 	 arnet.update.generation
        #
        #######################################################

    def getGeneration(self):
        return int(self.constantsDao.getConstant(self.genkey))

    def setGeneration(self, newGeneration):
        while True:
            try:
                conn = DB.pool().getConnection()
                cursor = conn.cursor()
                cursor.execute("update constants set value=%s where name=%s", (newGeneration, self.genkey))
                cursor.close()
                conn.close()
                return cursor.rowcount
            except MySQLdb.Error, e:
                print "Error %d: %s" % (e.args[0], e.args[1])
Exemple #3
0
 def test_db_constant_dao(self):
     c = ConstantsDAO()
     print 'constant arnet.update.generation is:', c.getConstant(
         "arnet.update.generation")
Exemple #4
0
	def test_db_constant_dao(self):
		c = ConstantsDAO()
		print 'constant arnet.update.generation is:', c.getConstant("arnet.update.generation")