I'm on a window 7 x64 machine, at a cmd.exe prompt.   This is what I tried: 

C:\jone>sqlite3 test2.db3SQLite version 3.8.5 2014-06-04 14:06:34Enter ".help" 
for usage hints.sqlite> CREATE TABLE Files (name TEXT PRIMARY KEY,contents 
BLOB);sqlite> INSERT INTO Files (name,contents) VALUES ('tsql.lis',X'$(od -A n 
-t x1 tsql.lis|tr -d '\r\n\t ')');Error: unrecognized token: "X'$(od -A n -t x1 
tsql.lis|tr -d '"sqlite> INSERT INTO Files (name,contents) VALUES 
('tsql.lis',X"$(od -A n -t x1 tsql.lis|tr -d '\r\n\t ')");Error: near ""$(od -A 
n -t x1 tsql.lis|tr -d '\r\n\t ')"": syntax errorsqlite>
I'm trying to store the file tsql.lis as a blob, and od.exe and tr.exe are in 
my path via the cygwin tree: 
can anybody tell me what is wrong  I got these instructions from by best guess 
at interpreting this: 

>I need to open a file and store the contents into the BLOB field.  Some of the 
>files are images and some are document templates.
>Can I do that using just SQL commands from a command line?
>
>Thanks,
>Gloria

Yes, here's a oneliner (tested on Solaris):

d=test.db3 ; echo "CREATE TABLE Files (name TEXT PRIMARY
KEY,contents BLOB);" | sqlite3 $d ; for f in yourfiles* ; do echo
"INSERT INTO Files (name,contents) VALUES ('$f',X'$(od -A n -t x1
$f|tr -d '\r\n\t ')');" | sqlite3 $d ; done 

HTH
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to