#从数据库中读取图片
#encoding = utf8
import pymysql
conn =pymysql.connect(host=“127.0.0.1”,user=“root”,passwd = “root”,
db = “test”)
cur = conn.cursor()
sql = “select img from images where img_id =1”
cur.execute(sql)
#元组里面拿到第一个数值
img = cur.fetchone()[0]
#创建一个图片
f2 = open(“6.jpg”,mode= “wb”)
f2.write(img)
f2.close()
print(img)
cur.close()
conn.close()
从数据库读取图片(2019-09-23)
最新推荐文章于 2021-01-18 22:20:47 发布