noel0217 发表于 2017-4-24 12:37:18

初试Python 操作Mysql

#!/usr/bin/python
# -*- coding: utf8 -*-
import MySQLdb
conn=MySQLdb.connect(host="localhost",user="root",passwd="phpcool",db="device")
cursor=conn.cursor()
cursor.execute("SET NAMES utf8")
cursor.execute("select * from attribute")
cds = cursor.fetchall()
for row in cds:
for r in row:
print r
print 10*"----"
页: [1]
查看完整版本: 初试Python 操作Mysql