python MySQLdb-9527
#!/usr/bin/env pythonimport 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]