Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26744
  • 博文数量: 38
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 390
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-29 22:54
文章分类

全部博文(38)

文章存档

2010年(38)

我的朋友
最近访客

分类: Python/Ruby

2010-05-31 13:28:45

突然想起了世界上最优雅的语言python

(why 最优雅,因为强制缩进,看起来的确比较好看)

1,先装MySQLdb库,官方下载的不行,搜到这个

2,遇到__init__.py什么什么的错误,

神级帖子save me

找到MySQLdb文件夹的中__init__.py,注释掉from sets import ImmutableSet
class DBAPISet(ImmutableSet):添加class DBAPISet(frozenset):;找到converters.py注释掉from sets import BaseSet, Set。然后修改第45行和129行中的Set为set。

3,开始读取book数据库

import MySQLdb
conn=MySQLdb.connect(host="localhost",user="root",passwd="744411",db="book")
cursor=conn.cursor()
cursor.execute("select * from book")
res=cursor.fetchall()
print res
cursor.close()
conn.close()



阅读(447) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~