def addLog(**kwargs): if ('message' not in kwargs): logging.warning('invalid params: message not exist') return -1 message = kwargs['message'] db_util = DBUtil() db_util.add_use_log(UseLog(message=message, log_time=datetime.now())) return 0
def verify(**kwargs): if ('serial_key' not in kwargs): logging.warning('invalid params: serial_key not exist') return -2 serial_key = kwargs['serial_key'] db_util = DBUtil() return db_util.check_serial(serial_key)
def test_get_account_data_mysql(): db_util = DBUtil() test_system = SystemInfo(sys_name='test_system', db_type=DatabaseType.mysql, db_ip='127.0.0.1', db_port='3306', db_name='wpd', db_table_name='user_table', db_column_username='******', db_column_password='******', db_password_encrypt_algorithm=EncryptAlgorithmType.md5) db_util.add_system(test_system) print '____________________%d' % test_system.id test_system.get_account_data(username='******', password='******')
def test_get_account_data_oracle(): db_util = DBUtil() test_system = SystemInfo(sys_name='test_system2', db_type=DatabaseType.oracle, db_ip='192.168.238.130', db_port='1521', db_name='ora11g', db_table_name='PM_BID_PROJECT_INFO', db_column_username='******', db_column_password='******', db_password_encrypt_algorithm=EncryptAlgorithmType.md5) db_util.add_system(test_system) print '____________________%d' % test_system.id test_system.get_account_data(username='******', password='******')
def test_sysinfo_manage(): db_util = DBUtil() #create demo_system = SystemInfo(sys_name='oa333', db_type=DatabaseType.oracle, db_ip='127.0.0.1', db_port='1521', db_name='db', db_table_name='accounts', db_column_username='******', db_column_password='******', db_password_encrypt_algorithm=EncryptAlgorithmType.md5) db_util.add_system(demo_system) for i in db_util.get_all_system(): print i #update demo_system.db_type = DatabaseType.mysql demo_system.db_port = '3306' #request idd = demo_system.id print '____________________%d' % idd s = db_util.get_system_by_id(idd) print s print '__ __ __ __ __ __ __ ___ ___%d' % idd #delete db_util.del_system(s) s = db_util.get_system_by_id(idd) print s