#!/usr/bin/python
# -*- coding: UTF-8 -*-
import MySQLdb
import getpass
password = getpass.getpass()
#password = raw_input("输入mysql密码:")
# 打开数据库连接
db = MySQLdb.connect("localhost", "root", password, "ztq", charset='utf8' )
# 使用cursor()方法获取操作游标
cursor = db.cursor()
# 使用execute方法执行SQL语句
cursor.execute("show tables;")
# 使用 fetchone() 方法获取一条数据
#data = cursor.fetchone()
data = cursor.fetchall()
print "表名:"
for d in data:
print "%s" % d
# 关闭数据库连接
db.close()