PythonCGI:如何将大型输出拆分为页面?
如何将python cgi输出拆分为页面。 示例循环结构: 而1:PythonCGI:如何将大型输出拆分为页面?,python,cgi,Python,Cgi,如何将python cgi输出拆分为页面。 示例循环结构: 而1: if x is true: c.execute("select m from n where id=%s") gene=c.fetchall() print "%s", (gene), else: print "NA" if y is true: c.execute("select p from q where id=%s") protein=c.fetchall() print "%
if x is true:
c.execute("select m from n where id=%s")
gene=c.fetchall()
print "%s", (gene),
else:
print "NA"
if y is true:
c.execute("select p from q where id=%s")
protein=c.fetchall()
print "%s", (protein),
else:
print "NA"
print "\n"
输出为数百万行。我想把输出分成几页,比如每页50行。我该怎么做?我感谢你的帮助。谢谢。使用“限制偏移量,限制”sql语句。此外,您还可以缓冲输出,并编写按页面(文件)拆分的数据。大致说明如何继续:
页面
编码到url中,该参数表示:“显示页码页面
”。这类似于http://xxx.abc.de/genes?page=3
,您必须修改脚本以检索此参数。这可以通过页面。。。检索页面+页面大小-1
。MySQL对此有limit
修饰符。看http://xxx.abc.de/genes?page=2
和http://xxx.abc.de/genes?page=4
我想,我无法修改select命令,因为循环中有多个select命令,这些命令将打印成一行。您是否有指向示例代码的链接?是否需要每个sql请求或所有数据响应中的50行?如果您有多个sql,您可以这样设置限制:限制偏移量,舍入(50个/U个sql查询)