1. 首页
  2. 数据库
  3. 其它
  4. python操作MySQL数据库的方法分享

python操作MySQL数据库的方法分享

上传者: 2021-01-01 02:10:21上传 PDF文件 50.66KB 热度 33次
我采用的是MySQLdb操作的MYSQL数据库。先来一个简单的例子吧: 复制代码 代码如下: 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
下载地址
用户评论