![](/img/trans.png)
[英]cursor.fetchmany vs DECLARE BINARY CURSOR and FETCH
[英]How to use fetchmany() to fetch the next set of results?
我想在Python中使用fetchmany(100)從MySql中獲取一百個結果。 但是我想知道是否有一種方法可以提取下一組結果,以防在提取的結果中找不到我想要的結果。 這樣就可以獲取下100個結果。
這可能嗎? 如果是的話,那怎么辦?
除了使用fetchmany(),還可以使用fetchall(),但在您的選擇查詢中包括以下內容:
SELECT * from data limit 00,30;
00
表示位置30
表示要作為結果輸出的行數。
因此,您可以使用每次獲取更多結果時都會增加的變量來介紹位置。
例如
position= 00
while True:
nothing = input("Do you want more input?")
data = c.execute("SELECT * from data limit {}, 50".format(amount))
data = c.fetchall()
position += 50
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.