Insert images into Sqlite database pyhton

preview_player
Показать описание

Code:
import sqlite3
from tkinter import *
from tkinter import filedialog

root = Tk()

#File dialog to select files
def filedialogs():
global get_image

#Image need to be conver into binary before insert into database
def conver_image_into_binary(filename):
with open(filename, 'rb') as file:
return photo_image

def insert_image():

for image in get_image:
insert_photo = conver_image_into_binary(image)
{'image': insert_photo })

#Create database in current file and create table if not exist

def create_database():

create_database()

select_image = Button(root, text="Select Image", command=filedialogs)

save_image = Button(root, text="Save", command=insert_image)

Рекомендации по теме
Комментарии
Автор

which best performance if we store image on directory vs we store as blob to sqlite?

TheRolldone
Автор

amazing, thank you for your special content. I have a question if you could help me, I have multiple variables to insert into the sqilte3 database with the image, and I tried to applicate your code but it doesn't work, and the error type is: image is not defined

ab-jv