예제 #1
0
 def testGetConIncSql(self):
     sqlReader = SqlReader(self.conf)
     sql = sqlReader.getConIncSql("2013-03-24 10:56:00")
     
     self.assertEqual(
              "SELECT * FROM test_collection " +
                  "WHERE datetime > 2013-03-24 10:56:00\n", sql)
예제 #2
0
class Transmitter():
    
    def __init__(self, conf):
        self.conf = conf
        self.conSql = None
        self.delSql = None
        self.sqlReader = SqlReader(conf)
        
    
    def transmitConData(self, dumpType):
        exporter = Exporter(self.conf)
        pusher = Pusher(self.conf)
        
        if dumpType == SqlReader.FULL:
            sql = self.sqlReader.getConSql()
        elif dumpType == SqlReader.INCR:
            sql = self.sqlReader.getConIncSql()
        exporter.execute(sql)
        
        subResult = exporter.fetchmany()
        while subResult:
            pusher.pushConData(subResult)
            subResult = exporter.fetchmany()
            
        exporter.close()
        pusher.close()
    
    def transmitDelData(self, dumpType):
        exporter = Exporter(self.conf)
        pusher = Pusher(self.conf)
        
        if dumpType == SqlReader.FULL:
            sql = self.sqlReader.getDelSql()
        elif dumpType == SqlReader.INCR:
            sql = self.sqlReader.getDelIncSql()
        exporter.execute(sql)
        
        subResult = exporter.fetchmany()
        while subResult:
            pusher.pushDelData(subResult)
            subResult = exporter.fetchmany()
            
        exporter.close()
        pusher.close()
    
    def transmit(self, dumpType):
        now = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        
        self.transmitConData(dumpType)
        self.transmitDelData(dumpType)
        
        timestampFile = open(self.conf.timestampFile , "w")
        timestampFile.write(now)
        timestampFile.close()
예제 #3
0
 def __init__(self, conf):
     self.conf = conf
     self.conSql = None
     self.delSql = None
     self.sqlReader = SqlReader(conf)