GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — How can i display image from mysql to python gui ? · Issue #1088 · realpython/python-guide

How can i display image from mysql to python gui ? #1088

New issue
Copy link
New issue
Copy link
Open
Open
How can i display image from mysql to python gui ?#1088
Copy link

Description

@2020Yasir-Sahibzada
2020Yasir-Sahibzada
opened on Jan 8, 2021
Issue body actions

I am trying , like this :

from tkinter import *
from io import BytesIO
window= Tk()
db=MySQLdb.connect("localhost","root","??","??")
cursor=db.cursor()
sql= "SELECT LOGO FROM SYSTEMDETAILS" cursor.execute(sql)
logo=cursor.fetchone()
img = Image.open(BytesIO(logo))
phimg = ImageTk.PhotoImage(img)
panel = Label(window, image = phimg)
panel.pack()

When i run this, it show error in line 9 , it want logo as an object but in here its tuple

Activity

  1. somanyadav commented on Dec 23, 2022

    @somanyadav
    somanyadav
    on Dec 23, 2022
    More actions

    Hello @2020Yasir-Sahibzada,

    I think you can try to access like this,

    logo = cursor.fetchone()
    img_data = logo[0]
    

    And after that you can use the BytesIO class to wrap the image data,

    img = Image.open(BytesIO(img_data))
    
  2. anuragdaksh7 commented on Jun 4, 2023

    @anuragdaksh7
    anuragdaksh7
    on Jun 4, 2023
    More actions

    Hey @2020Yasir-Sahibzada I think you didn't included mysql imports for the code
    adding them might solve your issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.