多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 查询一行数据 * 创建testSelectOne.py文件,查询一条学生信息 ~~~ #encoding=utf8 import MySQLdb try: conn=MySQLdb.connect(host='localhost',port=3306,db='test1',user='root',passwd='mysql',charset='utf8') cur=conn.cursor() cur.execute('select * from students where id=7') result=cur.fetchone() print result cur.close() conn.close() except Exception,e: print e.message ~~~ ## 查询多行数据 * 创建testSelectMany.py文件,查询一条学生信息 ~~~ #encoding=utf8 import MySQLdb try: conn=MySQLdb.connect(host='localhost',port=3306,db='test1',user='root',passwd='mysql',charset='utf8') cur=conn.cursor() cur.execute('select * from students') result=cur.fetchall() print result cur.close() conn.close() except Exception,e: print e.message ~~~