def add(cls, req): _ip = req.get('ip') _cpu = req.get('cpu') _ram = req.get('ram') _time = req.get('time') _sql = 'insert into performs(ip,cpu,ram,time) VALUES (%s,%s,%s,%s)' SQL.excute_sql(_sql, (_ip, _cpu, _ram, _time), False)
def log_execute(self, log_files): sql = 'DELETE FROM accesslog;' MySQLConnection.execute_sql(sql, fetch=False) sql = 'insert into accesslog(ip,url,status,count) values(%s, %s, %s, %s)' rt_dict = {} try: log_files = open(log_files, 'r') while True: line = log_files.readline() if not line: break logs = line.split() (ip, url, status) = logs[0], logs[6], logs[8] if (ip, url, status) not in rt_dict: rt_dict[(ip, url, status)] = 1 else: rt_dict[(ip, url, status)] += 1 log_files.close() # args_list = sorted(rt_dict.items(), key=lambda x:x[1], reverse=True) _count, _rt_list = MySQLConnection.bulker_commit_sql(sql, args=rt_dict.items()) return _count != 0 except BaseException as e: import traceback print traceback.format_exc() print e return False
def log2db(cls, logfile): MySQLConnection.execute_sql('DELETE FROM accesslog;', (), False) fhandler = open(logfile, 'r') rt_dict = {} while True: line = fhandler.readline() if line == '': break nodes = line.split() ip, url, code = nodes[0], nodes[6], nodes[8] key = (ip, url, code) if key not in rt_dict: rt_dict[key] = 1 else: rt_dict[key] = rt_dict[key] + 1 fhandler.close() rt_list = [] for _key, _cnt in rt_dict.items(): rt_list.append(_key + (_cnt, )) _sql = 'insert into accesslog(ip, url, code, cnt) values (%s, %s, %s, %s)' MySQLConnection.bulker_execute_sql(_sql, rt_list)
def add(cls, req): _ip = req.get('ip') _cpu = req.get('cpu') _mem = req.get('mem') _time =req.get('time') _sql = 'insert into performs(ip, cpu, mem, time)values(%s,%s,%s,%s)' MySQLConnection.execute_sql(_sql, (_ip, _cpu, _mem, _time), False)
def add(cls, req): _ip = req.get('ip') _cpu = req.get('cpu') _ram = req.get('ram') _time = req.get('time') _sql = 'insert into performs(ip,cpu,ram,time) values(%s,%s,%s,%s)' MySQLConnection.execute_sql(_sql, (_ip, _cpu, _ram, _time), False)
def log2db(log_files='', topn=10, fetch=True): sql = 'insert into accesslog(ip,url,status,count) values(%s,%s,%s,%s)' rt_dict = {} _rt = [] if fetch: # 查询数据 _columns = ('id', 'ip', 'url', 'status', 'count') sql = 'select * from accesslog order by count desc limit %s' _count, _rt_list = MySQLConnection.execute_log_sql(sql, args=(topn, ), fetch=True) for _list in _rt_list: _rt.append(dict(zip(_columns, _list))) return _rt else: # 写入数据 MySQLConnection.execute_sql('delete from accesslog', fetch=False) try: log_files = open(log_files, 'r') while True: line = log_files.readline() if not line: break logs = line.split() (ip, url, status) = logs[0], logs[6], logs[8] if (ip, url, status) not in rt_dict: rt_dict[(ip, url, status)] = 1 else: rt_dict[(ip, url, status)] += 1 log_files.close() _count, _rt_list = dbutils.execute_log_sql( sql, args_list=rt_dict.items(), fetch=False) return _count != 0 except: return False
def update(cls, _sn, _ip, _hostname, _os, _cpu, _ram, _disk, _idc_id, _admin, _business, _purchase_date, _warranty, _vendor, _model, _id): _sql = 'update assets set sn=%s,ip=%s,hostname=%s,os=%s,cpu=%s,ram=%s,disk=%s,idc_id=%s,admin=%s,business=%s,purchase_date=%s,warranty=%s,vendor=%s,model=%s where id=%s;' _args = (_sn, _ip, _hostname, _os, _cpu, _ram, _disk, _idc_id, _admin, _business, _purchase_date, _warranty, _vendor, _model, int(_id)) MySQLConnection.execute_sql(_sql, _args, fetch=False)
def idc_create(cls, name): _column = 'name' name = str(name) _sql = 'insert into idcs(name) values(%s);' _args = (name) #print _sql #print _args MySQLConnection.execute_sql(_sql, _args, fetch=False)
def create(self): _columns = self._columns[1::] _column_str = ','.join(_columns) _args = [] for _column in _columns: _args.append(self.ob.get(_column, '')) _sql = 'insert into assets({columns}) values({values})'.format( columns=_column_str, values=','.join(['%s'] * len(_columns))) MySQLConnection.execute_sql(_sql, _args, False)
def add(cls, req): _column_str = 'sn,ip,hostname,os,admin,business,vendor,model,idc_id,cpu,ram,disk,warranty,purchase_date' _columns = _column_str.split(',') _args = [] for _column in _columns: _args.append(req.get(_column, '')) _sql = 'INSERT INTO assets({columns}) VALUES({values})'.format(columns=_column_str, values=','.join(['%s'] * len(_columns))) MySQLConnection.execute_sql(_sql, _args, False)
def change_user(self, userid, updateage): user_list = self.get_users() for users in user_list: if users['age'] != updateage: _sql = 'update user set age=%s where id =%s' _args = (updateage, userid) MySQLConnection.execute_sql(_sql, _args, False)
def update(self): _columns = self._columns[1::] _values = [] _args = [] for _column in _columns: _values.append('{column}=%s'.format(column=_column)) _args.append(self.ob.get(_column, '')) _args.append(self.ob.get('id')) _sql = 'update assets SET {values} where id=%s'.format( values=','.join(_values)) MySQLConnection.execute_sql(_sql, _args)
def update(cls, req): _column_str = 'sn,ip,hostname,os,admin,business,vendor,model,idc_id,cpu,ram,disk,warranty,purchase_date' _columns = _column_str.split(',') _values = [] _args = [] for _column in _columns: _values.append('{column}=%s'.format(column=_column)) _args.append(req.get(_column, '')) _args.append(req.get('id')) _sql = 'UPDATE assets SET {values} WHERE id=%s'.format(values=','.join(_values)) MySQLConnection.execute_sql(_sql, _args, False)
def user_add(cls, params): username = params.get('username') password = params.get('password') age = params.get('age') telphone = params.get('telphone') email = params.get('email') _sql_select = 'select * from user where username = %s' _sql_insert = 'insert into user(username,password,age,telphone,email) values(%s,%s,%s,%s,%s)' agrs1 = (username, ) _sql_count, rt_list = SQL.excute_sql(_sql_select, agrs1) if _sql_count != 0: return False, username + '已存在,请尝试其他的名字' args2 = (username, md5_str(password), age, telphone, email) SQL.excute_sql(_sql_insert, args2) return True, '添加成功'
def validate_login(cls, username, password): _columns = ('id', 'username', 'password') _sql = 'select * from user where username=%s and password=md5(%s)' _cnt, _rt_list = MySQLConnection.execute_sql(_sql, (username, password), fetch=True) return dict(zip(_columns, _rt_list[0])) if _cnt != 0 else None
def delete(cls, id): _sql = 'update assets set status = 1 where id=%s' _args = (id, ) _cnt, _rtlist = SQL.excute_sql(_sql, _args) if _cnt != 0: return True, '删除成功' return False, '删除失败'
def get_list2(cls): _column = 'id,sn,ip,hostname,os,cpu,ram,disk,idc_id,admin,business,purchase_date,warranty,vendor,model' _columns = _column.split(',') _sql = 'select {column} from assets'.format(column=_column) _cnt, _rt_list = MySQLConnection.execute_sql(_sql) return [dict(zip(_columns, _line)) for _line in _rt_list]
def get_list(cls): _column = 'id,sn,ip,hostname,os,cpu,ram,disk,idc_name,admin,business,purchase_date,warranty,vendor,model,status' _columns = _column.split(',') _sql = 'select {column} from assets,idc_name where assets.status=0 and assets.idc_id = idc_name.idc_id;'.format( column=_column) _cnt, _rt_list = SQL.excute_sql(_sql) return [dict(zip(_columns, i)) for i in _rt_list]
def get_idc_name(cls): _sql = 'select idc_id,idc_name from idc_name' rt = [] _cnt, _rt_list = SQL.excute_sql(_sql) for i in _rt_list: rt.append(i) return rt
def change_passwd(cls, uid, upass): _sql = 'update user set password = %s where id = %s' _args = (md5_str(upass), uid) _sql_count, rt_list = SQL.excute_sql(_sql, _args) if _sql_count: return True, '修改成功' return False, '修改失败'
def log2_time_status(cls): _sql = 'select date_format(logtime,"%%Y-%%m-%%d %%H:00:00"),status,count(*) from access_logs2 where logtime >= %s group by logtime,status;' _last_time = time.strftime('2014-08-%d %H:%M:%S', time.localtime(time.time() - 4 * 24 * 60 * 60)) #最近24小时的 _cnt, _rt_list = SQL.excute_sql(_sql, (_last_time, )) _legends = [] _times = [] _datas = [] _temp_dict = {} for _time, _status, _cnt in _rt_list: if _status not in _legends: _legends.append(_status) if _time not in _times: _times.append(_time) _temp_dict.setdefault(_status, {}) _temp_dict[_status][_time] = _cnt for _status, _stat in _temp_dict.items(): _node = { 'name': _status, 'type': 'bar', 'barWidth': 30, 'stack': 'web_time_code', 'data': [_stat.get(x, 0) for x in _times] } _datas.append(_node) return _legends, _times, _datas
def validate_login(cls, username, password): _column = ("id", "username") password_md5 = cls.md5_str(password) _sql = 'select id,username from user_auth where username=%s and password=%s' #无非就是查询count _count, _rt_tuple = MySQLConnection.execute_sql( _sql, (username, password_md5)) return dict(zip(_column, _rt_tuple[0])) if _count != 0 else None
def user_del(cls, id, username): _sql = 'delete from user where id=%s and username=%s' args = (id, username) _sql_count, rt_list = SQL.excute_sql(_sql, args) if _sql_count != 0: return True return False
def update(self): sql = 'update user set job=%s, age=%s where id=%s' args = (self.job, self.age, self.id) count, rt_list = MySQLConnection.execute_sql(sql, args=args, fetch=False) return count != 0
def save(self): sql = 'insert into user(username,password,job,age) values(%s,md5(%s),%s,%s)' args = (self.username, self.password, self.job, self.age) count, rt_list = MySQLConnection.execute_sql(sql, args=args, fetch=False) return count != 0
def get_list(cls): column = 'id,sn,ip,hostname,idc_id,purchase_date,warranty,vendor,model,admin,business,cpu,ram,disk,os,status' columns = column.split(',') sql = 'select {column} from assets where status=0'.format( column=column) count, rt_list = MySQLConnection.execute_sql(sql, fetch=True) return [dict(zip(columns, line)) for line in rt_list]
def user_del(cls,id, username): _sql = 'delete from user where id=%s and username=%s' args = (id, username) _sql_count, rt_list = SQL.excute_sql(_sql, args) if _sql_count != 0: return True, '删除成功' return False, '删除失败'
def change_passwd(cls,uid, upass): _sql = 'update user set password = %s where id = %s' _args = (md5_str(upass), uid) print _args _sql_count, rt_list = SQL.excute_sql(_sql, _args) if _sql_count: return True, '修改成功' return False, '修改失败' # @classmethod # def user_reset(cls,id, username): # _sql = 'update user set password = %s where id=%s and username=%s' # newpassword = ''.join([choice(string.ascii_letters + string.digits) for i in range(8)]) # args = (md5_str(newpassword), id, username) # _sql_count, rt_list = SQL.excute_sql(_sql, args) # if _sql_count != 0: # return True, '重置成功', newpassword # return False, '重置失败', newpassword # # @classmethod # def validate_mpass(cls,params): # mgrpass = params.get('mgrpass') # mgruser = '******' # ip = params.get('ip') # cmd = params.get('cmd').split('\n') # _sql = 'select * from user where username=%s and password=%s' # _args = (mgruser,md5_str(mgrpass)) # _sql_count,rt_list = SQL.excute_sql(_sql,_args) # if _sql_count != 0 : # _ssh = Ssh_cmd(ip,cmd) # return _ssh.ssh_cmd() # return False,'管理员密码验证失败'
def get_info(cls, _sql=None, _count=None, _user=None, _id=None, username=None, _args=()): _rt = [] if _sql: _columns = ('id', 'ip', 'url', 'code', 'cnt') for i in _sql.split(): if i in ['drop', 'delete']: return False, u'sql语句中有危险操作!' elif _count: _sql = 'select * from logs limit %s;' _columns = ('id', 'ip', 'url', 'code', 'cnt') _args = (int(_count), ) _count = _count elif _id: _sql = 'select * from user where id=%s;' _args = (_id, ) _columns = ('id', 'username', 'password', 'age') elif username: _sql = "select * from user where username=%s;" _args = (username, ) _columns = ('id', 'username', 'password', 'age') else: _columns = ('id', 'username', 'password', 'age') _sql = 'select * from user;' _cnt, _rt_list = MySQLConnection.execute_sql(_sql, _args, fetch=True) for _line in _rt_list: _rt.append(dict(zip(_columns, _line))) return _rt, ''
def validate_login(cls, username, password): _column = ("id", "username") _sql = 'select id,username from user_auth where username=%s and password=md5(%s)' #无非就是查询count _count, _rt_tuple = MySQLConnection.execute_sql( _sql, (username, password)) print "_rt_tuple:", _rt_tuple return dict(zip(_column, _rt_tuple[0])) if _count != 0 else None
def validate(cls, asset_info, repeat=True): errors = {} for value in asset_info: if asset_info[value] == "": errors[value] = "%s为空" % value if errors != {}: return False, errors if not asset_info["cpu"].isdigit(): errors["cpu"] = "cpu核数只能写整数,请重新填写" if not asset_info["disk"].isdigit(): errors["disk"] = "硬盘大小只能写整数,请重新填写" if not asset_info["ram"].isdigit(): errors["ram"] = "内存大小只能写整数,请重新填写" if not asset_info["warranty"].isdigit(): errors["warranty"] = "保修时间只能写整数,请重新填写" if errors != {}: return False, errors if repeat: sql = 'select sn from assets where sn=%s' args = (asset_info['sn'], ) count, rt_list = MySQLConnection.execute_sql(sql, args) if count != 0: errors['sn'] = "sn编码重复,请重新输入" if errors != {}: return False, errors else: return True, {}
def user_add(cls,params): username = params.get('username') password = params.get('password') cname = params.get('cname') telphone = params.get('telphone') email = params.get('email') permission = params.get('permission', '0') _sql_select = 'select * from user where username = %s' _sql_insert = 'insert into user(username,password,cname,telphone,email,permission) values(%s,%s,%s,%s,%s,%s)' agrs1 = (username,) _sql_count, rt_list = SQL.excute_sql(_sql_select, agrs1) if _sql_count != 0: return False, username + '已存在,请尝试其他的名字' args2 = (username, md5_str(password), cname, telphone, email, permission) SQL.excute_sql(_sql_insert, args2) return True, '添加成功'
def get_by_key(cls, value, key='id'): _column = 'id,sn,ip,hostname,os,cpu,ram,disk,idc_id,admin,business,purchase_date,warranty,vendor,model' _columns = _column.split(',') _sql = 'SELECT {column} FROM assets WHERE status=0 and {key}=%s'.format(column=_column, key=key) _args = (value,) _count, _rt_list = MySQLConnection.execute_sql(_sql, _args) return None if _count == 0 else dict(zip(_columns, _rt_list[0]))
def get_list(cls): sql = 'select * from user' rt = [] columns = ("id", "username", "password", "age", "gender", "email") count, rt_list = MySQLConnection.execute_sql(sql) for line in rt_list: rt.append(dict(zip(columns, line))) return rt
def get_list(cls): colloens = ('id', 'username', 'password', 'cname', 'telphone', 'email', 'permission') _sql = 'select * from user' rt = [] sql_count, rt_list = SQL.excute_sql(_sql) # 函数调用 for i in rt_list: rt.append(dict(zip(colloens, i))) return rt
def stat_export(collections,tablename,ptname,date): _sql = 'select * from {tablename} where ptname = %s order by date'.format(tablename=tablename) _args = (ptname,) sql_count, rt_list = SQL.excute_sql(_sql,_args) rt = [] for i in rt_list: rt.append(dict(zip(collections,i))) return rt if sql_count != 0 else None
def get_by_id(cls,key, value): _column = 'id,sn,ip,hostname,os,purchase_date,warranty,vendor,model,idc_id,admin,application,business,cpu,mem,disk' _columns = _column.split(',') _sql = 'select * from assets where {key}=%s'.format(key=key) _cnt, _rt_list = MySQLConnection.execute_sql(_sql, (value,)) if _cnt !=0: return _cnt, dict(zip(_columns,_rt_list[0])) else: return _cnt, _rt_list
def get_list(cls, wheres=[]): _columns = ('id', 'username', 'password', 'age') _sql = 'select * from user where 1=1' _args = [] for _key, _value in wheres: _sql += ' AND {key} = %s'.format(key=_key) _args.append(_value) _count, _rt_list = MySQLConnection.execute_sql(_sql, _args) return [dict(zip(_columns, _line)) for _line in _rt_list]
def get_list(cls, ip): _sql = 'select cpu, mem, time from performs where ip=%s and time >=%s order by time asc' _args = (ip, time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()-60 * 60))) _count, _rt_list = MySQLConnection.execute_sql(_sql, _args) datetime_list = [] cpu_list = [] mem_list = [] for _cpu, _mem, _time in _rt_list: cpu_list.append(_cpu) mem_list.append(_mem) datetime_list.append(_time.strftime('%H:%M')) return datetime_list, cpu_list, mem_list
def user_update(cls,params): username = params.get('username') id = params.get('id') cname = params.get('cname') telphone = params.get('telphone') email = params.get('email') permission = params.get('permission','0') _sql = 'update user set cname=%s ,telphone=%s ,email=%s , permission=%s where id=%s and username=%s' args = (cname, telphone, email, permission, id, username) _sql_count, rt_list = SQL.excute_sql(_sql, args) if _sql_count != 0: return True, '更新成功' return False, '更新失败'
def get_users(cls, wheres=[]): _columns = ('id', 'username', 'password', 'age', 'phone', 'email') _sql = 'select * from user where 1=1' _args = [] print wheres for _key, _value in wheres: _sql += ' AND {key} = %s'.format(key=_key) _args.append(_value) _count, _rt_list = MySQLConnection.execute_sql(_sql, _args) _rt = [] for _line in _rt_list: # (6L, u'kk4', u'e10adc3949ba59abbe56e057f20f883e', 29L) _rt.append(dict(zip(_columns, _line))) return _rt
def has_alarm(ip): _sql = 'select cpu, mem from performs where ip = %s and time >=%s order by time desc limit %s' _time = datetime.datetime.now() - datetime.timedelta(minutes=5) _args = (ip, _time.strftime('%Y-%m-%d %H:%M:%S'), CNT) _rt_cnt, _rt_list = MySQLConnection.execute_sql(_sql, _args) if _rt_cnt < CNT: return False, False _cpu_alarm = True _mem_alarm = True for cpu, mem in _rt_list: if cpu < CPU_PERCENT: _cpu_alarm = False if mem < MEM_PERCENT: _mem_alarm = False return _cpu_alarm, _mem_alarm
def stat_import(params): _sql = 'insert into frame_stat(ptname,date,frame_49,frame_55,frame_60,frame_49_new,frame_55_new,frame_60_new) values (%s,%s,%s,%s,%s,%s,%s,%s)' _args_4399 = params['4399frame'] _args_7k7k = params['7k7kframe'] for _args in _args_4399,_args_7k7k: SQL.excute_sql(_sql,_args,fetch=False) _sql = 'insert into caton_stat(ptname,date,caton_5,caton_15,caton_30,caton_50,caton_70,caton_95,caton_100,caton_5_new,caton_15_new,caton_30_new,caton_50_new,caton_70_new,caton_95_new,caton_100_new) values ( \ %s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)' _args_4399 = params['4399caton'] _args_7k7k = params['7k7kcaton'] for _args in _args_4399,_args_7k7k: SQL.excute_sql(_sql, _args, fetch=False) _sql = 'insert into load_stat(ptname,date,load_config,load_res) values (%s,%s,%s,%s)' _args_4399 = params['4399load'] _args_7k7k = params['7k7kload'] for _args in _args_4399, _args_7k7k: SQL.excute_sql(_sql, _args, fetch=False) _sql = 'insert into memory_stat(ptname,date,memory_500,memory_700,memory_900,memory_1100) values (%s,%s,%s,%s,%s,%s)' _args_4399 = params['4399memory'] _args_7k7k = params['7k7kmemory'] for _args in _args_4399, _args_7k7k: SQL.excute_sql(_sql, _args, fetch=False) _sql = 'insert into mouse_stat(ptname,date,mouse_20,mouse_30,mouse_50,mouse_75,mouse_20_new,mouse_30_new,mouse_50_new,mouse_75_new) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)' _args_4399 = params['4399mouse'] _args_7k7k = params['7k7kmouse'] for _args in _args_4399, _args_7k7k: SQL.excute_sql(_sql, _args, fetch=False) _sql = 'insert into enter_game_stat(ptname,date,success,battle_res_load,army_success,room_success,lobby_success,frist_root_success,frist_lobby_success,frist_battle_success,fighting_drop, \ frist_fighting_drop,ladder_drop,frist_ladder_drop,trans_drop,browser,ladder_match) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)' _args_4399 = params['4399enter'] _args_7k7k = params['7k7kenter'] for _args in _args_4399, _args_7k7k: SQL.excute_sql(_sql, _args, fetch=False)
def validate_login(cls,username, password): _columns = ('id','username') _sql = 'select * from user where username = %s and password = %s' args = (username, md5_str(password)) sql_count, rt_list = SQL.excute_sql(_sql, args) return dict(zip(_columns,rt_list[0])) if sql_count != 0 else None
def save(self): _sql = 'insert into user(username, password, age) values(%s, md5(%s), %s)' _args = (self.username, self.password, self.age) MySQLConnection.execute_sql(_sql, _args, False)
def save(self): _sql = 'insert into user(username, password, age, phone, email) values(%s, %s, %s, %s, %s)' _args = (self.username, utils.md5_str(self.password), self.age, self.phone, self.email) MySQLConnection.execute_sql(_sql, _args, False)
def validate_login(cls, username, password): _columns = ('id', 'username') _sql = 'select id,username from user where username=%s and password=md5(%s)' _count, _rt_list = MySQLConnection.execute_sql(_sql, (username, password)) return dict(zip(_columns, _rt_list[0])) if _count != 0 else None
def add(cls, username, password, age): _sql = 'insert into user(username, password, age) values(%s, md5(%s), %s)' _args = (username, password, age) MySQLConnection.execute_sql(_sql, _args, False)
def get_list(cls, topn=10): _sql = 'select ip, url, code, cnt from accesslog order by cnt desc limit %s' _args = (topn, ) _count, _rt_list = MySQLConnection.execute_sql(_sql, _args) return _rt_list
def delete(cls, id): _sql = 'UPDATE assets SET status=1 WHERE id=%s' _args = (id, ) MySQLConnection.execute_sql(_sql, _args, False)
def execute_sql(cls, sql, args=(), fetch=True): return MySQLConnection.execute_sql(sql, args, fetch)
def add(cls,username, password, age, phone, email): _sql = 'insert into user(username, password, age, phone, email) values(%s, %s, %s, %s, %s)' _args = (username, utils.md5_str(password), age, phone, email) MySQLConnection.execute_sql(_sql, _args, False)
def change_user_password(cls,uid, upassword): _sql = 'update user set password=%s where id=%s' MySQLConnection.execute_sql(_sql, (utils.md5_str(upassword), uid), False)
def update_user(cls,uid, password, age, phone, email): _sql = 'update user set password=%s, age=%s, phone=%s, email=%s where id=%s' MySQLConnection.execute_sql(_sql, (utils.md5_str(password), age, phone, email, uid),False)
def get_list(cls): _column = 'id,sn,ip,hostname,os,cpu,ram,disk,idc_id,admin,business,purchase_date,warranty,vendor,model' _columns = _column.split(',') _sql = 'SELECT {column} FROM assets WHERE status=0'.format(column=_column) _count, _rt_list = MySQLConnection.execute_sql(_sql) return [dict(zip(_columns, _line)) for _line in _rt_list]
def Assets_create(cls,sn, ip, hostname, os, purchase_date, warranty, vendor, model, idcs, admin, application,business, cpu, mem, disk): _sql = 'insert into assets(sn, ip, hostname, os, purchase_date, warranty, vendor, model, idc_id, admin, application,business, cpu, mem, disk) values(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s)' args = (sn, ip, hostname, os, purchase_date, warranty, vendor, model, idcs, admin, application,business, cpu, mem, disk) MySQLConnection.execute_sql(_sql, args, False) return True