readme and build.sh cleanup
authorShane Jaroch <nutratracker@protonmail.com>
Thu, 21 Apr 2022 23:28:49 +0000 (19:28 -0400)
committerShane Jaroch <nutratracker@protonmail.com>
Thu, 21 Apr 2022 23:28:49 +0000 (19:28 -0400)
TODO: add Makefile

README.rst
data/dep-graph.yml [deleted file]
sql/build.sh

index 5570ce6eb67bbb14c2ee80f67110005a1c91aee1..68af8e1b090b3d9541416abc1d635d401d33efca 100644 (file)
@@ -15,7 +15,7 @@ Pypi page:  https://pypi.org/project/nutra
 Building the database
 #########################
 
-1. Install ``access2csv`` dependency,
+1. Install ``access2csv`` dependency (requires ``mvn`` command in step 2),
 
 .. code-block:: bash
 
@@ -42,12 +42,20 @@ Building the database
 | 3   | 0.0.2    | Thu 06 Aug 2020 09:21:39 AM EDT   |
 +-----+----------+-----------------------------------+
 
-4. Create the database with
+4. i. (Optional) Enforce foreign keys with your ``~/.sqliterc`` file,
+
+::
+
+    .headers on
+    .mode column
+    PRAGMA foreign_keys = 1;
+
+4. ii. Create the database with
 
 .. code-block:: bash
 
     cd ../sql
-    ./build.sh
+    ./build.sh X.X.X  # e.g. 0.0.8
 
 
 5. Verify the tables (again inside the SQL shell :code:`sqlite3 usda.sqlite`),
diff --git a/data/dep-graph.yml b/data/dep-graph.yml
deleted file mode 100644 (file)
index dcffe81..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-- NUTR_DEF
-- FD_GROUP
-  - FOOD_DES
-    - SRC_CD
-    - DERIV_CD
-      - NUT_DATA
-    - LANGDESC
-      - LANGUAL
-    - DATA_SRC
-      - DATSRCLN
-    - WEIGHT
-    - FOOTNOTE
index c626d0616dc499a7e6dd4b5de9157d4cc6aea40e..295e16fe59e98c7d3de01a757095aac2ff38a08f 100755 (executable)
@@ -1,36 +1,28 @@
-#!/bin/bash -e
+#!/bin/bash -ex
 
 VERSION=$1
-if [[ $VERSION == '' ]]
+if [ -z $VERSION ]
 then
-    echo Error: NEED TO SPECIFY VERSION, e.g. 0.0.3
+    echo Error: NEED TO SPECIFY VERSION, e.g. build.sh 0.0.3
     exit
 fi
 
 cd "$(dirname "$0")"
-# printf "\\n\e[1;31m\e[0m\\n"
+# lives in sql/
 
-rm_cmd="rm -f usda.sqlite"
-printf "\\n\e[1;31m${rm_cmd}\e[0m\\n\n"
-$rm_cmd
+# Remove existing
+rm -f usda.sqlite
 
-pack_msg="==> Pack usda.sqlite-$VERSION"
-printf "\\n\\x1b[32m${pack_msg}\x1b[0m\n\n"
+printf "\\n\\x1b[32m%s\x1b[0m\n\n" "==> Pack usda.sqlite v$VERSION"
 
-# Create SQL file
-pack_cmd="sqlite3 usda.sqlite \".read init.sql\""
-printf "\\n\e[1;31m${pack_cmd}\e[0m\\n"
-bash -exec "$pack_cmd"
+# Create sqlite db
+sqlite3 usda.sqlite ".read init.sql"
 
 # Compress xzip
-tar_cmd="tar cJvf usda.sqlite-$VERSION.tar.xz usda.sqlite"
-printf "\\n\e[1;31m${tar_cmd}\e[0m\\n"
-$tar_cmd
+tar cJf usda.sqlite-$VERSION.tar.xz usda.sqlite
 
 # Clean up
-# printf "\\n\e[1;31m${rm_cmd}\e[0m\\n"
-# $rm_cmd
-
-mv_cmd="mv usda.sqlite-$VERSION.tar.xz dist"
-printf "\\n\e[1;31m${mv_cmd}\e[0m\\n\n"
-$mv_cmd
+# rm ???
+# overwrite existing?
+mkdir -p dist
+mv usda.sqlite-$VERSION.tar.xz dist