Re: [sqlite] Trouble importing hex encoded blob

2012-05-14 Thread Black, Michael (IS)
.@sqlite.org [sqlite-users-boun...@sqlite.org] on behalf of Black, Michael (IS) [michael.bla...@ngc.com] Sent: Monday, May 14, 2012 12:28 PM To: General Discussion of SQLite Database Subject: EXT :Re: [sqlite] Trouble importing hex encoded blob Looks like it goes inside this loop in 3.7.12 at li

Re: [sqlite] Trouble importing hex encoded blob

2012-05-14 Thread Black, Michael (IS)
Looks like it goes inside this loop in 3.7.12 at line 1883 of shell.c. Could we get maybe a pragma ".mode csvblob" or such and have this made a permanet part of the shell? for(i=0; i Hey Jim, > > I downloaded the source or 3.7.12 from sqlite.org and can't find that code. > > $ ls > shel

Re: [sqlite] Trouble importing hex encoded blob

2012-05-14 Thread Jim Morris
Joshua, It doesn't exist in the standard version. We added it in-house to aid development and testing. The code I posted was the changes we made to the 3.5.9 shell.c in addition to adding an existing hex to byte function from our libraries. If you can compile a new shell the existing shell

Re: [sqlite] Trouble importing hex encoded blob

2012-05-14 Thread Joshua Shanks
Hey Jim, I downloaded the source or 3.7.12 from sqlite.org and can't find that code. $ ls shell.c sqlite3.c sqlite3ext.h sqlite3.h $ head -n3 sqlite3.c /** ** This file is an amalgamation of many separate C source file

Re: [sqlite] Trouble importing hex encoded blob

2012-05-14 Thread Joshua Shanks
Seems like with or without the X it doesn't do the same thing as an import $ cat sample.tsv import X'1234' X'1234' import 1234 1234 CREATE TABLE samples ( method varchar(64), value blob ); insert INTO samples (method, value) VALUES ("insert - null", null); insert INTO samples (method, v

Re: [sqlite] Trouble importing hex encoded blob

2012-05-14 Thread Black, Michael (IS)
I updated my csvimport utility to allow hex fields. So hex fields like X'01020304' will get imported as blobs if the option is enabled. Sooo test.csv: X'0001063500',X'00' X'0001063501',X'01' csvimport test.csv test.db t csvimport -x test.csv test.db t

Re: [sqlite] Trouble importing hex encoded blob

2012-05-14 Thread Jim Morris
We added blob import on an old version of the shell, 3.5.9. Using a simple HexToByte function. To function: static int do_meta_command(char *zLine, struct callback_data *p){ Added:unsigned char * blobBuffer = NULL; In the loop // * Bind cached values to prepared statement. *

Re: [sqlite] Trouble importing hex encoded blob

2012-05-11 Thread Joshua Shanks
I peeked at the source code real quick and it looks like it just converts the contents of the file into a bunch of SQL that is essentially opening a transaction and doing an insert for each row followed by a commit. This suggest I just need to format it differently so I'll play around with that tom

Re: [sqlite] Trouble importing hex encoded blob

2012-05-11 Thread Richard Hipp
On Fri, May 11, 2012 at 10:13 PM, Joshua Shanks wrote: > I set the separator to tab and then in the file it is > > X'somevalue'\tX'someothervalue'\n > X'morestuff'\tX'evenmore'\n > > but with real hex values > > According to the documentation > That document you quote is describing the SQL langa

Re: [sqlite] Trouble importing hex encoded blob

2012-05-11 Thread Joshua Shanks
I set the separator to tab and then in the file it is X'somevalue'\tX'someothervalue'\n X'morestuff'\tX'evenmore'\n but with real hex values According to the documentation BLOB literals are string literals containing hexadecimal data and preceded by a single "x" or "X" character. For example:

Re: [sqlite] Trouble importing hex encoded blob

2012-05-11 Thread Simon Slavin
On 12 May 2012, at 2:01am, Joshua Shanks wrote: > But when I try to use the .import method the values get imported as > the string "X'" instead of the hex blob value and don't get pulled > out correctly. .import is for .csv files. What are you putting in the .csv file to express a value i

[sqlite] Trouble importing hex encoded blob

2012-05-11 Thread Joshua Shanks
I've tried searching for awhile and haven't had any luck. I'm able to store and retrieve blob data using inserts and the hex encoded literals like this INSERT INTO rolled (roll1, roll2) VALUES (X'0001063500',X'00'); But when I try to use the .import method the values get impor