本文整理匯總了Python中custom.db.mysql.Custom_MySQL.executemany方法的典型用法代碼示例。如果您正苦於以下問題:Python Custom_MySQL.executemany方法的具體用法?Python Custom_MySQL.executemany怎麽用?Python Custom_MySQL.executemany使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類custom.db.mysql.Custom_MySQL
的用法示例。
在下文中一共展示了Custom_MySQL.executemany方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: call_back
# 需要導入模塊: from custom.db.mysql import Custom_MySQL [as 別名]
# 或者: from custom.db.mysql.Custom_MySQL import executemany [as 別名]
def call_back(self,data=[]):
db = Custom_MySQL(using='log')
sql = "insert into last_ip (id,ip,login_ip) values(null,%s,%s)"
for result in data:
if int(result['flag']) == 1:
ips = json.loads(result['data'])
host = result['ip']
set_param =[]
for ip in ips:
set_param.append(tuple([host,ip]))
db.executemany(sql,set_param)
db.commit()
else:
print result
示例2: call_back
# 需要導入模塊: from custom.db.mysql import Custom_MySQL [as 別名]
# 或者: from custom.db.mysql.Custom_MySQL import executemany [as 別名]
def call_back(self,data=[]):
db = Custom_MySQL(using='log')
last_insert_id = db.insert('cpu_batch',**{})
db.commit()
sql = "insert into cpu_detail (id,ip,cpu_used) values(null,%s,%s)"
for result in data:
if int(result['flag']) == 1:
ips = json.loads(result['data'])
host = result['ip']
set_param =[]
for ip in ips:
set_param.append(tuple([host,ip]))
db.executemany(sql,set_param)
db.commit()
else:
print result