File tree 3 files changed +35
-0
lines changed
3 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ database.db
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ function sql {
4
+ sqlite3 database.db " $@ "
5
+ }
6
+
7
+ sql ' .read setup.sql'
8
+
9
+ if [ $# -eq 0 ]; then
10
+ sql ' select rowid, description from blobs'
11
+ exit
12
+ fi
13
+
14
+ _tmpdir=$( mktemp -d)
15
+ echo $_tmpdir >&2
16
+
17
+ # trap "rm -rf $_tmpdir" EXIT
18
+
19
+ itemID=" $1 " ; shift
20
+
21
+ _fifo=$_tmpdir /fifo
22
+ # mkfifo $_fifo
23
+
24
+ if [ " $itemID " == " -" ]; then
25
+ cat /dev/stdin >> $_fifo
26
+ sql " insert into blobs(description, data) values ('$* ', readfile('$_fifo '))"
27
+ else
28
+ sql " select writefile('$_fifo ', data) from blobs where rowid = $itemID " > /dev/null
29
+ cat $_fifo
30
+ fi
Original file line number Diff line number Diff line change
1
+ create table if not exists blobs(
2
+ description text default " " ,
3
+ data blob not null
4
+ )
You can’t perform that action at this time.
0 commit comments