Save multi images in sql table
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sangeetha SRank #212 · 11.4K reputationPosted Sep 16, 2025, 5:31 AM EDT
INSERTstatements.import sqlite3
conn = sqlite3.connect('images.db')
cursor = conn.cursor()
cursor.execute('''
CREATE TABLE IF NOT EXISTS images (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT,
image BLOB
)
''')
conn.commit()
Jayraj ChhayaRank #304 · 8.2K reputationPosted Sep 18, 2025, 6:53 AM EDT
The best way is to store images in a separate table with one row per image. Either save them as BLOB/VARBINARY (binary data) or, preferably, store just the file path/URL and keep the images in file storage (server, AWS S3, Azure, etc.) for better performance.