classBuffer(object):MAXSIZE=8192def__init__(self,conn,sql):self.conn=connself.sql=sqlself.buffer=[]defappend(self,data):self.buffer.append(data)iflen(self.buffer)>self.MAXSIZE:self.flush()defflush(self):data,self.buffer=self.buffer,[]curr=self.conn.cursor()curr.executemany(self.sql,data)self.conn.commit()#hereareyourcodeforinitdatabaseconnectconn_srcandconn_store...buff=Buffer(conn_store,"insertintosybase_uservalues(%s,%s)")sql_query="selecta.id,a.namefromuser_infoawherea.id=%s"curr_src=conn_src.cursor()curr_src.execute(sql_query,'0001')forrowincurr_src:buff.append(row)buff.flush()
網(wǎng)站導(dǎo)航
- zblogPHP模板zbpkf
- zblog免費(fèi)模板zblogfree
- zblog模板學(xué)習(xí)zblogxuexi
- zblogPHP仿站zbpfang
首頁(yè)后端開(kāi)發(fā)python如何用ansible+python實(shí)現(xiàn)一個(gè)定時(shí)將數(shù)據(jù)插入influxdb數(shù)據(jù)庫(kù)?