1.connect def conn(ip,user,passWord,database): con = mdb.connect(ip,user,password,database) cur = con.cursor()
1.connect
def conn(ip,user,passWord,database):
con = mdb.connect(ip,user,password,database)
cur = con.cursor()
return cur
2.select
SELECT ip,env from hosts ORDER BY 1, 2
for row in cur.fetchall():
print row
('172.x.x.x', 'prod')
('PROBLEM: 172.x.x.x Table open cache too small\r\nservice_name: Table open cache too small\r\nService_status: PROBLEM\r\nService_severity: InfORMation\r\nItem values:\r\nCheck_service_ip:172.x.x.x\r\nCheck_service_name:Mysql.status[Open_tables]\r\nCheck_service_vlaue:4059\r\nCheck_service_time:2018.03.01 09:54:43',)
3.update
--结束END--
本文标题: python 操作MySQL数据库
本文链接: https://www.lsjlt.com/news/182940.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0