update sql, add readme
authorShane Jaroch <nutratracker@protonmail.com>
Wed, 5 Aug 2020 23:33:55 +0000 (19:33 -0400)
committerShane Jaroch <nutratracker@protonmail.com>
Wed, 5 Aug 2020 23:36:40 +0000 (19:36 -0400)
README.rst [new file with mode: 0644]
data/import.sql
data/tables.sql

diff --git a/README.rst b/README.rst
new file mode 100644 (file)
index 0000000..6a601e0
--- /dev/null
@@ -0,0 +1,38 @@
+**********
+ nutra-db
+**********
+
+.. image:: https://api.travis-ci.com/gamesguru/ntdb.svg?branch=master
+    :target: https://travis-ci.com/gamesguru/ntdb
+
+Python, SQL and CSV files for setting up portable SQL database.
+
+See CLI:    https://github.com/nutratech/cli
+
+Pypi page:  https://pypi.org/project/nutra
+
+Building the database
+#########################
+
+1. Inside ``/data`` folder, run :code:`bash setup.sh`
+
+2. Now run :code:`python3 process.py`
+
+3. Create the database with :code:`sqlite3 nutra.db`
+
+4. Create the tables, import the data, and save:
+
+.. code-block:: bash
+
+    .read tables.sql
+    .read import.sql
+    .exit
+
+Tables (Relational Design)
+##########################
+
+See :code:`sql/tables.sql` for details.
+
+This is frequently updated, see :code:`docs/` for more info.
+
+.. image:: docs/nutra.svg
index 2ba1ca4381e33db69c47c4336c87ad2bc860b542..7ca8ebb740eaa2916c9adf2bcf24e6aae3295754 100644 (file)
@@ -7,7 +7,7 @@
 
 .import '| tail -n +2 nt/src_cd.csv' src_cd
 .import '| tail -n +2 nt/deriv_cd.csv' deriv_cd
--- .import '| tail -n +2 nt/nut_data.csv' nut_data
+.import '| tail -n +2 nt/nut_data.csv' nut_data
 
 
 .import '| tail -n +2 nt/lang_desc.csv' lang_desc
index c8d226f1d4cdb07dfd3ec0901ef64c6b44b4da1d..c44d49e53515246ffe098418313b08167d32fd16 100644 (file)
@@ -33,8 +33,8 @@ CREATE TABLE fdgrp (
 
 CREATE TABLE food_des (
   id integer PRIMARY KEY AUTOINCREMENT,
-  fdgrp_id int,
-  long_desc text,
+  fdgrp_id int NOT NULL,
+  long_desc text NOT NULL,
   shrt_desc text,
   com_name text,
   manufac_name text,
@@ -60,9 +60,9 @@ CREATE TABLE deriv_cd (
 );
 
 CREATE TABLE nut_data (
-  food_id int,
-  nutr_id int,
-  nutr_val float,
+  food_id int NOT NULL,
+  nutr_id int NOT NULL,
+  nutr_val float NOT NULL,
   num_data_pts int,
   std_err float,
   src_cd text,
@@ -76,7 +76,8 @@ CREATE TABLE nut_data (
   low_eb float,
   up_eb float,
   stat_cmt text,
-  add_mod_date date
+  add_mod_date date,
+  cc text
 );
 
 CREATE TABLE lang_desc (