Thank you for the input. THis is what I tried, char*data = "THIS \\\"IS 'BLAH" This is a blob data of 40 bytes that I wanted to store, so all bytes after BLAH are all '\0'. So I created a insert query like this, by converting the blob in hexadecimal format,
Insert into table values (X'54484953205c2249532027424c41480000000000000'); -> 0 are 40 times. in the sqlite shell, select * from table, shows me the data as it is in X'hex' format. X'54484953205c2249532027424c41480000000000000000000000000000000000000000 0000000000' And when I try to retrieve it using sqlite3_column_blob, and try to print that blob I see the same X'hex' string instead of "THIS \\\"IS 'BLAH". Why is this behaviour? We give input in hex format for sqlite to understand that this is a blob and not a text and it shoudl make the appropriate conversion to store it internally. I know sqlite treats blob and text the same, but is there no way that I can get the binary data as I have? Do I again need to convert the hex string into my binary blob buffer? I hope people understood what I am trying to ask out here. -Shailesh > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Shailesh Birari > Sent: Tuesday, June 03, 2008 5:02 PM > To: General Discussion of SQLite Database > Subject: Re: [sqlite] Forming a query with BLOB with null characters > > Thanks I found that later. > sprintf would rather be a costly operation. > > -Shailesh > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Dan > > Sent: Tuesday, June 03, 2008 3:47 PM > > To: General Discussion of SQLite Database > > Subject: Re: [sqlite] Forming a query with BLOB with null characters > > > > > > On Jun 3, 2008, at 4:20 PM, Shailesh Birari wrote: > > > > > Hello, > > > I have a simple question here. I want to generate a insert query > > > (char*) > > > which will insert a blob in a table. This blob is nothing but a C > > > structure in my program. > > > > > > So the query would be something like this > > > > > > INSERT INTO table1 VALUES > > > ('12323232\0\0\0\023232323\0\0\023232323\0\03445\0') > > > > > > where the blob field is having some null characters in it. I know > > > there is a way to use bind blob but I want to create this > > query. Are > > > there any APIs that sqlite provides so that given a blob of > > x bytes, > > > it will generate corresponding string to be appended in the query? > > > > > > I looked at sqlite3_snprintf, but it will print only till > first \0 > > > character in the string. I want to escape all the \0s till > > my x bytes > > > of buffer? > > > > > > Can someone please give me any pointers for this ? > > > > Use the blob literal syntax described here: > > > > http://www.sqlite.org/lang_expr.html > > > > Dan. > > > > _______________________________________________ > > sqlite-users mailing list > > sqlite-users@sqlite.org > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users