From 3c6bd67b02dfb5dd7ac11455741530c3ebd034fa Mon Sep 17 00:00:00 2001 From: Louie S Date: Fri, 5 May 2023 19:25:50 -0700 Subject: Create lib subdirectory for common functions --- src/lib/create_table | 7 +++++++ src/lib/insert | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 src/lib/create_table create mode 100644 src/lib/insert (limited to 'src/lib') diff --git a/src/lib/create_table b/src/lib/create_table new file mode 100644 index 0000000..a783c50 --- /dev/null +++ b/src/lib/create_table @@ -0,0 +1,7 @@ +create_table() { + DB_PATH="$1" + + sqlite3 "$DB_PATH" "CREATE TABLE IF NOT EXISTS searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);" + sqlite3 "$DB_PATH" "CREATE UNIQUE INDEX IF NOT EXISTS anchor ON searchIndex (name, type, path);" +} + diff --git a/src/lib/insert b/src/lib/insert new file mode 100644 index 0000000..baa13bd --- /dev/null +++ b/src/lib/insert @@ -0,0 +1,8 @@ +insert() { + DB_PATH="$1" + NAME="$2" + TYPE="$3" + PAGE_PATH="$4" + + sqlite3 "$DB_PATH" "INSERT INTO searchIndex(name, type, path) VALUES (\"$NAME\",\"$TYPE\",\"libc/$PAGE_PATH\");" +} -- cgit