We can collect binary data stored in Blob column from SQLite database. To display such data we have to use io ( Core tools for working with streams) and PIL ( Python Image Library ).
from PIL import Image
import io
Our binary data is available in row[2]
image = Image.open(io.BytesIO(row[2]))
import matplotlib.pyplot as plt
plt.imshow(image)
plt.show()
Full code to manage SQLite Blob column data in google platform is here
from sqlalchemy import create_engine,text
from sqlalchemy.exc import SQLAlchemyError
my_conn=create_engine("sqlite:///student_blob.db"+'?check_same_thread=False')
my_conn=my_conn.connect()
from PIL import Image
import io
my_data=(1) # ID of the row to display
q="SELECT * FROM student_profile WHERE id=1" # query with place holders
try:
my_cursor=my_conn.execute(text(q))
r_set=my_cursor.fetchone()
except SQLAlchemyError as e:
#error=str(e.__dict__['orig'])
print(e)
else:
student=str(r_set[0])+','+r_set[1]
#print(student)
image = Image.open(io.BytesIO(r_set[2]))
import matplotlib.pyplot as plt
plt.imshow(image)
plt.show()