Python学习之MySQLdb模块
import MySQLdbdb=MySQLdb.connect(host='127.0.0.1',user='jialebi',passwd='jialebi123',db='dream_android_game_center')
cur=db.cursor()
try:
cur.execute("SELECT * FROM account")
rows=cur.fetchall()
except MySQLdb.Error,e:
try:
print "MySQL Error [%d] : %s" % (e.args,e.args)
except IndexError:
print "MySQL Error: %s" % str(e)
for row in rows:
for col in row:
print "%s," %col
print "\n"
页:
[1]