我有一个python脚本,用于进行sql查询。问题是我的虚拟机只有2GB的RAM,而且有些sql查询的RAM太密集,因此内核会自动终止脚本。如何使这段代码更有效地使用RAM?我想在PostgresSQL代码中实现分页。我该怎么做?有人知道这一点的简单实现吗?我将非常感谢你的帮助!在
更新代码from __future__ import print_function
try:
import psycopg2
except ImportError:
raise ImportError('\n\033[33mpsycopg2 library missing. pip install psycopg2\033[1;m\n')
sys.exit(1)
import re
import sys
import json
import pprint
import time
outfilepath = "crtsh_output/crtsh_flat_file"
DB_HOST = 'crt.sh'
DB_NAME = 'certwatch'
DB_USER = 'guest'
# DELAY = 0
def connect_to_db():
start = 0
offset = 10
flag = True
while flag:
filepath = 'forager.txt'
with open(filepath) as fp: