Save image into SQLlite DB

This, in fact, is actually what I do. As I scan the incoming data stream and pick out the images, I put them into a temporary in-memory SQLite database, and then when all data has been read in, write the images to disk as image files and retain the path information for subsequent use. Much the best way.

1 Like

Depends on the image size KBs vs MBs ?

Mike, do you have an example of this? I’m looking to do this with the app I’m building and I could not find any example on this on xojo.

It’s often better to store images outside the database (in a folder near the database) and then store a reference to the image (probably you’d just need the file name) in the database.

If you store a lot of images in the database file, it will get very big very fast.

Is there an example of that? I agree on storing the images outside of the database and want to know if I can reference an example of it somewhere. The examples on xojo were only drag/drop and GetFolderItem images unless I’m overlooking the GetFolderItem.

Only thing that I can think of is creating a text field to open the image directory than having the image popup on the canvas. When saving the data, the text field with the directory will be saved to the database instead of the picture. That way on the listbox when a name is selected it will look for the ID with the image directory (text field) and pull the picture onto the canvas.

When I’ve done this (storing pictures outside the database), I create a unique id for the picture. You can use an ID generated by the database or create your own (I often use something about the date and time and some random letters. This has worked very well, but I don’t have millions of users).

Then you have the folder where all the pictures will go. You name the picture using your ID with an appropriate extension (e.g. .png, .jpg), save it to the folder, and store the name in the database.

Hope this helps.