本文整理汇总了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