python操作数据库
2,526 阅读
import MySQLdb
# 建立连接
conn = MySQLdb.connect(host="127.0.0.1",user="root",passwd="112233",db="qianyang",charset='utf8')
cur = conn.cursor()
# 操作数据
cur.execute('select * from user_info_and_topic_5topicand50word limit 10')
rows = cur.fetchall()
print rows
conn.close()
