SQLite Forum

Confused about blobs
Login
Oh, you want the format for encoding a blob in SQL Injection attack format.

That is specified as X'\<hexbytes\>...'

INSERT INTO t (integer, blob) values (57, X'4F8E72487B');

sqlite3_bind* is used to allow a program to talk to SQLite3.  The above might be:

int i = 57;  
unsigned char* b = {0x4F, 0x8E, 0x72, 0x48, 0x7B};  
sqlite_stmt* stmt;  

sqlite3\_prepare\_v2(db, "insert into t (integer, blob) values (?,?)",-1,&stmt, 0);  
sqlite3\_bind\_int(stmt, 1, i);  
sqlite3\_bind\_blob(stmt, 2, b, 5, SQLITE_TRANSIENT);  
sqlite3\_exec(stmt);  
sqlite3\_finalize(stmt);  

where the ? are "positional parameters" and you are "binding" the integer i to the first parameter and the blob b (of 5 bytes in length) to the second parameter.