Avatar of Dolamite Jenkins
Dolamite Jenkins
Flag for United States of America asked on

read a list of images into sqlite 'wb'

import sqlite3
conn=sqlite3.connect('facial.db')
cursor = conn.cursor()

#=========================Insert Photos =======================
# Convert digital data to binary format
def convertToBinaryData(images):
    for images in Directory:
        with open(images, 'wb') as f:
            photo = f.read()
        name= "Pix"+1
       

    cursor.execute("""INSERT INTO faces_file (name, photo) VALUES (?,?) """,(name,photo)

Open in new window

convertToBinaryData(images)
conn.commit()
cursor.close()
conn.close()

Open in new window

photos are in the below directory and I want to read the list into my data base

Directory/
photo1.jpg
photo2.jpg
photo3.jpg

1. trying to read this list of Binary images into data base.... I can do it one at a time which is to slow

2. need to photos from Directory into a list to be encoded (Opencv) 
* python3* sqlite3Python

Avatar of undefined
Last Comment
David Favor

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
David Favor

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Dolamite Jenkins

ASKER
thank you for the guidance 
David Favor

You're welcome!

Note: If you do store BLOBs in Sqlite3 https://www.sqlite.org/limits.html states max size is 2G, which is likely sufficient for any image + best to keep this limit in mind.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23