#include <stdio.h> #include <sqlite3.h> #include <stdlib.h> static sqlite3 *db=NULL; static sqlite3_stmt *stmt=NULL; FILE *fp; long filesize=0; char *fflie; int main(int argc, char *argv[]) { int rc,i,j; rc = sqlite3_open("dishes.db", &db); rc = sqlite3_prepare(db, "update dishes_table set dish_image=?where dish_name='x';", -1, &stmt, 0); fp=fopen("x.jpg","rb"); if(fp != NULL) { fseek(fp, 0, SEEK_END); filesize = ftell(fp); fseek(fp, 0, SEEK_SET); ffile = (char *)malloc(filesize + 1); size_t sz = fread(ffile, sizeof(char), filesize+1, fp); fclose(fp); } sqlite3_bind_blob(stmt, 1, ffile, filesize, NULL); rc=sqlite3_step(stmt); free(ffile); sqlite3_finalize(stmt); sqlite3_close(db); return 0; }