예제 #1
0
파일: sync.py 프로젝트: cash2one/cms-5
class SetData():
    def __init__(self):
        dbc = ini.get_items('MySQL')
        self.db = SimpleMysql(host=dbc['host'],
                              db=dbc['db'],
                              user=dbc['user'],
                              passwd=dbc['passwd'])

    def to_mysql(self, function, kwargs, time, table):
        if not table: return

        l, id = self.db.IsExistsinSQL(table, dict(kwargs))
        if l == 0:
            result = self.db.insert(table, dict(kwargs))
        elif l == 1:
            result = self.db.update(table, dict(kwargs), id)
        self.db.commit()
        logging.info('Complete sync - function: %s, table: %s, result: %s' %
                     (function, table, result))