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)
- aws eks node 自动化扩展工具 Karpenter - 8月 10, 2022
- ReplicationController and ReplicaSet in Kubernetes - 12月 20, 2021
- public key fingerprint - 5月 27, 2021