Generation

generate functionSat, 04 Mar 2023

api to store image to sql

void SqlDb::insert_image(string img_id, string img_path) { //write your code here int n = img_path.length(); char path[n+1]; strcpy(path, img_path.c_str()); Mat img = imread(path, 1); stringstream ss(stringstream::in | stringstream::out); ss << img_id; string mystr = ss.str(); string query = "INSERT INTO images (id, img) VALUES (" + mystr + ", decode('" + img_path + "', 'base64'));"; const char* q = query.c_str(); //cout << q << endl; execute(q); }

Questions about programming?Chat with your personal AI assistant