mysql - 将 mysql 数据库中的图像(BLOB)显示到 tkinter 窗口

标签 mysql python-2.7 raspberry-pi

我的数据库包含一个名为 LOGO 的图像(BLOB)。我想在 python TkInter 窗口上显示图像

 import Tkinter
    window= Tk()
    db= MySQLdb.connect("localhost","root","anup","NursecallDB")
    cursor=db.cursor()
    sql= "SELECT LOGO FROM SYSTEMDETAILS"
    cursor.execute(sql)
    logo=cursor.fetchone()
    img =PhotoImage(logo)
    panel = Tkinter.Label(window, image = img)
    panel.grid(row=0,rowspan=5,columnspan=2)
    window.mainloop()

当我运行这个程序时,它显示错误

panel = Tkinter.Label(window, image = img)
TypeError:_str_returned non-string(type tuple) 

最佳答案

将图像上传到文件夹并将路径插入数据库。如果logo是图片的路径。然后程序就可以工作了。

关于mysql - 将 mysql 数据库中的图像(BLOB)显示到 tkinter 窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29407479/

相关文章:

Python -- matplotlib 椭圆曲线

linux - 如何显示启动时运行的脚本的终端?

php - 备份mysql数据

Python 2.7 类型错误 : __init__() takes exactly 4 arguments (1 given)

mysql - 进入数据库后如何获得Mario Kart Wii记分牌积分

python-2.7 - ConfigParser 在通过 crontab 运行时不加载部分

Node.js - 用户目录中不存在 package.json

python - import pyttsx 在 python 2.7 中有效,但在 python3 中无效

mysql - 将带有 id 的 mySQL 表转换为带有 _id 的 MongoDB 表

php - 刷新数据库并删除条目