def log_incep_op(sqltext,dbtag,mycreatetime): lastlogin = mycreatetime create_time = mycreatetime username = '******' sqltype='incept' ipaddr = 'localhost' log = Oper_log (user=username,sqltext=sqltext,sqltype=sqltype,login_time=lastlogin,create_time=create_time,dbname='',dbtag=dbtag,ipaddr=ipaddr) log.save() return 1
def log_incep_op(sqltext,dbtag,request,mycreatetime): user = User.objects.get(username=request.user.username) lastlogin = user.last_login create_time = mycreatetime username = user.username sqltype='incept' ipaddr = func.get_client_ip(request) log = Oper_log (user=username,sqltext=sqltext,sqltype=sqltype,login_time=lastlogin,create_time=create_time,dbname='',dbtag=dbtag,ipaddr=ipaddr) log.save() return 1
def log_mysql_op(user,sqltext,mydbname,dbtag,request): user = User.objects.get(username=user) #lastlogin = user.last_login+datetime.timedelta(hours=8) #create_time = timezone.now()+datetime.timedelta(hours=8) lastlogin = user.last_login create_time = timezone.now() username = user.username sqltype=sqltext.split()[0].lower() #获取ip地址 ipaddr = get_client_ip(request) log = Oper_log (user=username,sqltext=sqltext,sqltype=sqltype,login_time=lastlogin,create_time=create_time,dbname=mydbname,dbtag=dbtag,ipaddr=ipaddr) log.save() return 1
def log_mysql_op(user,sqltext,mydbname,dbtag,request): user = User.objects.get(username=user) #lastlogin = user.last_login+datetime.timedelta(hours=8) #create_time = datetime.datetime.now()+datetime.timedelta(hours=8) lastlogin = user.last_login create_time = datetime.datetime.now() username = user.username sqltype=sqltext.split()[0].lower() #获取ip地址 ipaddr = get_client_ip(request) log = Oper_log (user=username,sqltext=sqltext,sqltype=sqltype,login_time=lastlogin,create_time=create_time,dbname=mydbname,dbtag=dbtag,ipaddr=ipaddr) log.save() return 1
def log_oracle_op(user,sqltext,mydbname,dbtag,ipaddr): user = User.objects.get(username=user) #lastlogin = user.last_login+datetime.timedelta(hours=8) #create_time = datetime.datetime.now()+datetime.timedelta(hours=8) lastlogin = user.last_login create_time = datetime.datetime.now() username = user.username sqltype=sqltext.split()[0].lower() if sqltype in ['desc','describe']: sqltype='show' #获取ip地址 log = Oper_log (user=username,sqltext=sqltext,sqltype=sqltype,login_time=lastlogin,create_time=create_time,dbname=mydbname,dbtag=dbtag,ipaddr=ipaddr) log.save() return 1
def log_mongo_op(sqltext, dbtag, tbname, request): user = User.objects.get(username=request.user.username) lastlogin = user.last_login create_time = datetime.datetime.now() username = user.username sqltype = 'select' ipaddr = get_client_ip(request) log = Oper_log(user=username, sqltext=sqltext, sqltype=sqltype, login_time=lastlogin, create_time=create_time, dbname=tbname, dbtag=dbtag, ipaddr=ipaddr) log.save() return 1