mysql模块学习:python操作MySQL数据库

来源:互联网 发布:linux工程师经验之谈 编辑:程序博客网 时间:2024/05/16 09:50

先看个简单的例子:

import MySQLdb try:    conn=MySQLdb.connect(host='localhost',user='root',passwd='root',db='test',port=3306)    cur=conn.cursor()    cur.execute('select * from user')    cur.close()    conn.close()except MySQLdb.Error,e:     print "Mysql Error %d: %s" % (e.args[0], e.args[1])

0 0