sqlite - Insert data into blob sqlite - Insert data into blob shell shell

sqlite - Insert data into blob


There is no built-in or shell function to read a file into a blob.

However, with the help of the hexdump tool, it's possible to transform a file's contents into a blob literal:

echo "insert into mytable(bindata, somefk) " \     "values(x'"$(hexdump -v -e '1/1 "%02x"' /tmp/somefile)"', 1);"

This command can then be piped into the sqlite3 shell.