import sqlite3
conn = sqlite3.connect("database.db")
c = conn.cursor()
# get the first image from the database
c.execute("SELECT image FROM images LIMIT 1")
rows = c.fetchall()
conn.close()
# image binary is stored in the first element of each row (we only have one row)
# write images to disk
with open("test_image.jpeg", "wb") as file:
file.write(rows[0][0])