self.cr.execute(sql, )
# res = self.cr.fetchmany(1000)
while True:
res = self.cr.fetchmany(1000)
print(len(res),res)
if not res:
break
return res
- fetchmany 和
fetchall()
类似,只是可以读取指定行数的数据量,当指定数据量小于实际数据量时,可以重复读取 - 如果使用fetchall() 来读取数据,如果数据量太大,放在一个列表中,可能放不下,就可以使用fetchmany()分批读取的方式.