发布网友 发布时间:2022-04-20 07:36
共2个回答
热心网友 时间:2022-04-09 06:29
class Buffer(object):
MAXSIZE = 8192
def __init__(self, conn, sql):
self.conn = conn
self.sql = sql
self.buffer = []
def append(self, data):
self.buffer.append(data)
if len(self.buffer) > self.MAXSIZE:
self.flush()
def flush(self):
data, self.buffer = self.buffer, []
curr = self.conn.cursor()
curr.executemany(self.sql, data)
self.conn.commit()
# here are your code for init database connect conn_src and conn_store...
buff = Buffer(conn_store, "insert into sybase_user values (%s, %s)")
sql_query = "select a.id, a.name from user_info a where a.id=%s"
curr_src = conn_src.cursor()
curr_src.execute(sql_query, '0001')
for row in curr_src:
buff.append(row)
buff.flush()
热心网友 时间:2022-04-09 07:47
要读多少条数据?追问每次一条数据