hb_sz 发表于 2018-8-11 08:17:43

python MySQLdb-9527

#!/usr/bin/env python  
import MySQLdb
  
try:
  
    conn=MySQLdb.connect(host='localhost',user='root',passwd='123456',db='mysql',port=3306)
  
    cur=conn.cursor()
  
    cur.execute('show databases;')
  
    for data in cur.fetchall():
  
      print data
  
    cur.close()
  
    conn.close()
  
except MySQLdb.Error,e:
  
    print("mysql Error %d: %s " % (e.args,e.args))
页: [1]
查看完整版本: python MySQLdb-9527