how to store image file into database using python

Recommended Answers

All 2 Replies

You could just save the file path to the database and reference it in your program.

connect = sqlite3.connect(database)
cursor = connect.cursor()
cursor.execute(SELECT * FROM images WHERE image = ("/home/debian/image.jpg"))
file = []
for row in self.cursor:
    file.append(row)
print file[:]

cursor.close()
connect.commit()

You can use the PIL(python image library) to convert an image to a string and store the string in your database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.