/api/exportoraceldata/?dbservice=tlyy&dbip=10.5.100.232&dbuser=tlcbuser&dbpass=tlcbuser&exporttable=DJANGO&tiaojian=where+1%3D1
-------------------
where 1=1
-------------------
STIME
NAME
ID
SELECT trim(ID),
SELECT trim(ID), trim(NAME),
SELECT trim(ID), trim(NAME), trim(STIME)
SELECT trim(ID), trim(NAME), trim(STIME) from tlcbuser.DJANGO where 1=1
def exportoraceldata(req):
print req.get_full_path()
dbservice= req.GET['dbservice']
dbip= req.GET['dbip']
dbuser= req.GET['dbuser']
dbpass= req.GET['dbpass']
exporttable= req.GET['exporttable']
if req.GET['tiaojian']:
tiaojian=req.GET['tiaojian']
else:
tiaojian=''
print '-------------------'
print tiaojian
print '-------------------'
String=random.randint(0,99999999)
code=str(String)
output=commands.getoutput("perl /root/sbin/unload_fulltable.pl %s %s %s %s %s '%s' %s " %(dbservice,dbip,dbuser,dbpass,exporttable,tiaojian,code) )
print output
file=exporttable+'.'+str(String)+'.txt'
commands.getoutput("gzip /ftp/download/%s" % file)
url='http://10.5.100.232/download/'+exporttable+'.'+str(String)+'.txt'+'.gz'
return HttpResponse(url)
这里传入的where 1=1 需要对%s 加上''引号