ITPub博客

首页 > IT职业 > IT生活 > python 操作MySQL数据库

python 操作MySQL数据库

IT生活 作者:greatleaf 时间:2021-09-09 09:27:02 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 smallrnservice_name: Table open cache too smallrnService_status: PROBLEMrnService_severity: InformationrnItem values:rnCheck_service_ip:172.x.x.xrnCheck_service_name:mysql.status[Open_tables]rnCheck_service_vlaue:4059rnCheck_service_time:2018.03.01 09:54:43',)

3.update

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4236/viewspace-2809946/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: CentOS 7 Yum安装PHP
请登录后发表评论 登录
全部评论

注册时间:2019-08-12

  • 博文量
    76
  • 访问量
    610