首页 > 数据库技术 > 详细

python 操作MySQL数据库

时间:2018-03-01 11:33:13      阅读:198      评论:0      收藏:0      [点我收藏+]
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

python 操作MySQL数据库

原文:http://blog.51cto.com/szgb17/2074166

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!