怎么樣的Python腳本進(jìn)行MySQL對(duì)所有表收集統(tǒng)計(jì)信息

運(yùn)用Python腳本進(jìn)行MySQL對(duì)所有表收集統(tǒng)計(jì)信息,針對(duì)這個(gè)問(wèn)題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問(wèn)題的小伙伴找到更簡(jiǎn)單易行的方法。

成都網(wǎng)絡(luò)公司-成都網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)公司十年經(jīng)驗(yàn)成就非凡,專(zhuān)業(yè)從事成都網(wǎng)站建設(shè)、成都做網(wǎng)站,成都網(wǎng)頁(yè)設(shè)計(jì),成都網(wǎng)頁(yè)制作,軟文發(fā)布平臺(tái),一元廣告等。十年來(lái)已成功提供全面的成都網(wǎng)站建設(shè)方案,打造行業(yè)特色的成都網(wǎng)站建設(shè)案例,建站熱線:18982081108,我們期待您的來(lái)電!

  1. [root@MySQL01 script]# vim analyze.py

  2. #!/usr/bin/env python

  3. # -*-encoding:utf8-*-

  4. #

  5. import MySQLdb

  6. import time

  7. step = 0

  8. db = MySQLdb.connect(host = '192.168.56.101',port = 3306,user = 'neo', passwd = 'neo' , db = 'information_schema')

  9. conn = db.cursor()

  10. sql = '''select TABLE_SCHEMA, table_name from information_schema.tables where table_schema not in ('information_schema', 'performance_schema', 'mysql') '''

  11. # print sql

  12. conn.execute(sql)

  13. if conn.rowcount > 0:

  14.         for item in conn.fetchall():

  15.                 sql = '''analyze table %s.%s''' % (item[0], item[1])

  16.                 print sql + ' operation executes successfully!'

  17.                 conn.execute(sql)

  18. time.sleep(0.5)

  19. conn.close()

  20. db.close()

  21. # 執(zhí)行腳本

  22. [root@MySQL01 script]# python2.6 analyze.py

  23. analyze table test.area operation executes

  24. analyze table test.class operation executes

關(guān)于運(yùn)用Python腳本進(jìn)行MySQL對(duì)所有表收集統(tǒng)計(jì)信息問(wèn)題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒(méi)有解開(kāi),可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識(shí)。

新聞名稱(chēng):怎么樣的Python腳本進(jìn)行MySQL對(duì)所有表收集統(tǒng)計(jì)信息
當(dāng)前路徑:http://muchs.cn/article38/iehhsp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站制作、小程序開(kāi)發(fā)、App設(shè)計(jì)、電子商務(wù)移動(dòng)網(wǎng)站建設(shè)、定制網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司