On Wed, Aug 6, 2014 at 6:34 AM, Tony Papadimitriou <to...@acm.org> wrote:
> Unless I'm misusing it, I believe the shell readfile() function reads a > file as text, not binary. I haven't checked writefile() for the same > problem on writing. > > This is how I use it, is this not correct? > > create table t1(a blob); > insert into t1 values(readfile('binfile')); > select * from t1; > > I always see text and I expect to see one of the following cases: > 1. a hex sequence regardless of file type > 2. text (if the file was text), or a hex sequence if it was binary. > > Instead, I see text when dealing with text files, and truncated text (up > to the first zero) when dealing with binary. > > Am I misusing it? > To see hex output, use SELECT quote(a) FROM t1; The shell always prints BLOBs as just the bytes within the blob, not translated to hex. It has always done this. For 14 years. Example: CREATE TABLE t1(a BLOB); INSERT INTO t1(a) VALUES(x'78797a7a79'); SELECT a FROM t1; The above prints: xyzzy -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users