SQLite Forum

How to use BLOB in C program
Login
A project I am working on involves automatically logging data from a test setup by reading some instrumentation during very long tests. That part works fine. I am adding sqlite to the data collection program (written in C) to use sqlite as "the file format" for the massive amount of data collected. Currently the system simply writes a massive csv file that is then imported into excel. ugh. Literally hours spent after each test manually processing data. So I wrote a C program that talks to the equipment, snags the data, then organizes it into a sqlite database. Much easier to find and grab data of interest after the test saving hours of work.

Handling numbers and text is no problem, works fine. During the post processing, my program creates and displays some graphs of the data. The current process involves literal cut and paste of the graphs. Screen shot, print out, cut out graph, tape into log book. So I am trying to make this program into a digital log book where all the data and graphs are in a single sqlite file.

I can programmatically convert the graphs in the post processing into a PNG or JPEG image file. I want to save that image as a BLOB in the table with the test data.

I never used BLOB before and confused how to insert and extract data using a BLOB. The syntax is confusing from the few examples I found on the internet which seem to use BIND to do the task. 

Assume I have the image in memory as a char array of bytes. 

I need an example in C of an INSERT statement how I put a binary block of memory into a BLOB, and conversely extracting the bytes from the BLOB into a memory array.