Пример #1
0
def run():
    colums = [[
        'Approved vendor number', 'Individual /Co Name', 'Individual /company',
        'Shareholder/ director of the Co', 'BR /ID copy',
        'Authorization letter', 'address1', 'address2', 'address3', 'address4',
        'Contact information (telephone)', 'Relevant department head ',
        'Financial controller', 'BPM reference number'
    ]]
    rows = find_data()
    Common.create_csv('supplier', colums, rows)
    pass
Пример #2
0
def recover():
    """数据回滚"""
    logging.info(Common.get_current_function_name())
    datestr = Common.NOW
    for tbl in TABLES:
        tbl_bak = 'bak_' + datestr + '_' + tbl
        sql = "DROP TABLE " + tbl + ";"
        logging.info(sql)
        sql = "RENAME TABLE " + tbl_bak + " TO " + tbl + ";"
        logging.info(sql)
        # try:
        #     Common.DB.execute(sql)
        #     Common.conn.commit()
        # except Exception as e:
        #     Common.conn.rollback()
        #     logging.error('MySQL error:' + str(e.args[0]) + str(e.args[1]))
        #     sys.exit(1)
        # logging.info('recover:' + tbl + ' from ' + tbl_bak)
    return
Пример #3
0
def backup():
    """数据备份"""
    logging.info(Common.get_current_function_name())
    datestr = Common.NOW
    for tbl in TABLES:
        tbl_new = 'bak_' + datestr + '_' + tbl
        sql = "CREATE TABLE IF NOT EXISTS " + tbl_new + " LIKE " + tbl + ";"
        logging.info(sql)
        # Common.DB.execute(sql)

        sql = "INSERT " + tbl_new + " SELECT * FROM " + tbl + ";"
        logging.info(sql)
        # try:
        #     Common.DB.execute(sql)
        #     Common.conn.commit()
        # except Exception as e:
        #     Common.conn.rollback()
        #     logging.error('MySQL error:' + str(e.args[0]) + str(e.args[1]))
        #     sys.exit(1)
        # logging.info('backup:' + tbl + ',' + tbl_new)
    return
Пример #4
0
import logging
import include.Common as Common
from libs.RedisQueue import RedisQueue


def test():
    # Common.red.set('test1', 'test string')
    # rq = RedisQueue('testQueue')
    # for i in range(5):
    #     rq.put(i)
    print(1)


if __name__ == "__main__":
    if len(sys.argv) > 1:
        Common.logInt(Common.LOGPATH + 'scripts_' + Common.NOW + '.log')
        logging.info('*' * 6 + ' script start ' + '*' * 6)
        # eval func
        funcs = sys.argv[1:]
        for func in funcs:
            eval(func)()
    else:
        sys.stderr.write("""Usage:  %s [Option]
Option
test
""" % sys.argv[0])
        sys.exit(1)

    Common.DB.close()
    logging.info('*' * 6 + ' script end ' + '*' * 6)