Python operation MySQL Database

Source: Internet
Author: User
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 the 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\n Service_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 operation MySQL Database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.