1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#!/usr/bin/env python # coding=utf-8 # first install : yum install MySQL-python import MySQLdb try: conn = MySQLdb.connect(host='localhost',user='root',passwd='yourpasswd',port=3306) cur=conn.cursor() conn.select_db('mysql') count = cur.execute('select count(*) from user') print count cur.close() conn.close() except MySQLdb.Error,e: print "Mysql Error %d: %s" % (e.args[0], e.args[1]) |
Latest posts by Zhiming Zhang (see all)
- 什么是ami - 二月 22, 2021
- istio Ingress Gateways - 十一月 25, 2020
- Istio VirtualService - 十一月 23, 2020