2006年06月20日 星期二 18:00
python-chinese, 为什么我保存图片文件不是完整的,少一部分.数据库中保存的是完整的图片信息.谢谢! import pymssql dbstring="select zp_zkz,zp_photo from t_zp" con = pymssql.connect( host='192.168.1.206', user='', password='', database='zs' ) cur = con.cursor() #执行SQL语句 cur.execute( str( dbstring ) ) for zpinfo in cur.fetchall(): print "zkzh is %s" % ( zpinfo[0] ) # print zpinfo[1] filename = zpinfo[0] + ".jpg" f=open( filename, "wb" ) f.write(zpinfo[1].read()) f.close() con.close() print "完成!" -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060620/4d4d5a87/attachment.html
2006年06月20日 星期二 20:42
可能是因为pymssql 最多主能处理字段长度4096吧~ 呵呵~ 至少存取text的时候是~ 具体有什么解决方法还不知道(除了重新编译pymssql) 在 06-6-20,ly9713 at gmail.com<ly9713 at gmail.com> 写道: > > python-chinese, > > 为什么我保存图片文件不是完整的,少一部分.数据库中保存的是完整的图片信息.谢谢! > > import pymssql > dbstring="select zp_zkz,zp_photo from t_zp" > con = pymssql.connect( host='192.168.1.206', user='', password='', > database='zs' ) > cur = con.cursor() > #执行SQL语句 > cur.execute( str( dbstring ) ) > for zpinfo in cur.fetchall(): > print "zkzh is %s" % ( zpinfo[0] ) > # print zpinfo[1] > > filename = zpinfo[0] + ".jpg" > f=open( filename, "wb" ) > f.write(zpinfo[1].read()) > f.close() > con.close() > print "完成!" > > > > _______________________________________________ > python-chinese > Post: send python-chinese at lists.python.cn > Subscribe: send subscribe to > python-chinese-request at lists.python.cn > Unsubscribe: send unsubscribe to > python-chinese-request at lists.python.cn > Detail Info: > http://python.cn/mailman/listinfo/python-chinese > >
Zeuux © 2025
京ICP备05028076号