From: Shane Jaroch Date: Thu, 21 Apr 2022 23:28:49 +0000 (-0400) Subject: readme and build.sh cleanup X-Git-Tag: 0.0.9~5 X-Git-Url: https://git.nutra.tk/v1?a=commitdiff_plain;h=43c078c092c9a4e2c5e669c520fd4fcc4a4f11be;p=nutratech%2Fusda-sqlite.git readme and build.sh cleanup TODO: add Makefile --- diff --git a/README.rst b/README.rst index 5570ce6..68af8e1 100644 --- a/README.rst +++ b/README.rst @@ -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 index dcffe81..0000000 --- a/data/dep-graph.yml +++ /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 diff --git a/sql/build.sh b/sql/build.sh index c626d06..295e16f 100755 --- a/sql/build.sh +++ b/sql/build.sh @@ -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