作者BlgAtlfans (BLG_Eric)
看板Python
标题[问题] psycopg2 itersize参数问题
时间Sun Sep 23 01:57:24 2018
小弟我知道这个参数的用途
但是有一部份的程式逻辑不是很清楚
因此想请问
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://webptt.com/cn.aspx?n=bbs/Python/M.1537639047.A.FC3.html
1F:推 kenduest: itersize : Read/write attribute specifying the numbe 09/23 15:53
2F:→ kenduest: r of rows to fetch from the backend at each network 09/23 15:53
3F:→ kenduest: roundtrip during iteration on a named cursor. The d 09/23 15:53
4F:→ kenduest: efault is 2000. 09/23 15:53
5F:→ kenduest: 文件是写网路沟通底层一轮处理的数量 09/23 15:54
6F:推 kenduest: 你的需求应该是使用 fetchmany(10000) 09/23 15:56
7F:→ BlgAtlfans: 好的 感谢Ken大解释 09/23 22:01