看板 Python 關於我們 聯絡資訊
小弟我知道這個參數的用途 但是有一部份的程式邏輯不是很清楚 因此想請問 import psycopg2 as pg conn = pg.connect('string') cursor = conn.cursor('name') cursor.itersize = 10000 cursor.execute('sql_command LIMIT 1000000') 照理說這時候cursor的執行方式應該是 以一次10000筆的方式回傳sql執行的結果 但是如果我底下接著用 cursor.fetchall() 應該要抓到10000筆的資料才對 但是結果吐出的卻是1000000筆的資料 想請問我的想法哪裡錯了? 感謝各位高手指導 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.193.176.122 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1537639047.A.FC3.html
kenduest: itersize : Read/write attribute specifying the numbe 09/23 15:53
kenduest: r of rows to fetch from the backend at each network 09/23 15:53
kenduest: roundtrip during iteration on a named cursor. The d 09/23 15:53
kenduest: efault is 2000. 09/23 15:53
kenduest: 文件是寫網路溝通底層一輪處理的數量 09/23 15:54
kenduest: 你的需求應該是使用 fetchmany(10000) 09/23 15:56
BlgAtlfans: 好的 感謝Ken大解釋 09/23 22:01