From: Shane Jaroch Date: Thu, 26 May 2022 20:48:28 +0000 (-0400) Subject: wip X-Git-Tag: 0.0.5~6 X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=3b13b4843c01944a41f5dc3b5f9bea1d090a1ba7;p=nutratech%2Fnt-sqlite.git wip --- diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..39f8d0d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,42 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +max_line_length = 100 + + +[*.{py}] +max_line_length = 88 + + +[*.sql] +indent_size = 2 + + +[*.{yaml,yml}] +indent_size = 2 + + +[Makefile] +indent_style = tab +max_line_length = 120 + + +[*.md] +max_line_length = 90 +trim_trailing_whitespace = false + + +[*.rst] +max_line_length = 79 + + +[{COMMIT_EDITMSG,MERGE_MSG,SQUASH_MSG}] +max_line_length = 72 + diff --git a/README.rst b/README.rst index 34f2b37..3dd58c8 100644 --- a/README.rst +++ b/README.rst @@ -15,7 +15,8 @@ Pypi page: https://pypi.org/project/nutra Building the database ######################### -1. If you are committing database changes, add a line to ``data/version.csv`` (e.g. ``id=4`` is the latest in this case), +1. If you are committing database changes, add a line to ``data/version.csv`` + (e.g. ``id=4`` is the latest in this case), +-----+----------+-------------+------------------+ | id | version | created | notes | @@ -41,7 +42,8 @@ Building the database make test -4. If everything looks good, commit and update submodules in the ``cli`` (python) and ``nt-android`` (java) repos. +4. If everything looks good, commit and update submodules in the + ``cli`` (python) and ``nt-android`` (java) repos. Tables (Relational Design) diff --git a/docs/nt.svg b/docs/nt.svg index 5153e11..4f1af30 100644 --- a/docs/nt.svg +++ b/docs/nt.svg @@ -50,31 +50,29 @@ profiles - -profiles - -id* -integer -name -text -eula -int -gender -text -dob -date -act_lvl -int -goal_wt -real -goal_bf -real -bmr_eq_id -int -bf_eq_id -int -created -int + +profiles + +id* +integer +name +text +gender +text +dob +date +act_lvl +int +goal_wt +real +goal_bf +real +bmr_eq_id +int +bf_eq_id +int +created +int @@ -125,8 +123,8 @@ biometric_log->profiles - - + + @@ -266,8 +264,8 @@ food_log->profiles - - + + @@ -340,9 +338,9 @@ food_costs food_id* -integer +int profile_id* -integer +int cost real diff --git a/sql/__init__.py b/sql/__init__.py index 0c6c92e..64d209a 100755 --- a/sql/__init__.py +++ b/sql/__init__.py @@ -45,6 +45,8 @@ def build_ntsqlite(verbose=False): query = "INSERT INTO {0} VALUES ({1});".format( # nosec: B608 table_name, values ) + print(query) + exit() cur.executemany(query, reader) cur.close() diff --git a/sql/tables.sql b/sql/tables.sql index 1770cf0..01cdf9f 100644 --- a/sql/tables.sql +++ b/sql/tables.sql @@ -14,7 +14,11 @@ -- You should have received a copy of the GNU General Public License -- along with this program. If not, see . -CREATE TABLE version( id integer PRIMARY KEY AUTOINCREMENT, version text NOT NULL UNIQUE, created date NOT NULL, notes text +CREATE TABLE `version` ( + id integer PRIMARY KEY AUTOINCREMENT, + `version` text NOT NULL UNIQUE, + created date NOT NULL, + notes text ); -- TODO: enforce FK constraint across two DBs? @@ -25,12 +29,12 @@ CREATE TABLE version( id integer PRIMARY KEY AUTOINCREMENT, version text NOT NUL CREATE TABLE bmr_eqs ( id integer PRIMARY KEY AUTOINCREMENT, - name text NOT NULL + name text NOT NULL UNIQUE ); CREATE TABLE bf_eqs ( id integer PRIMARY KEY AUTOINCREMENT, - name text NOT NULL + name text NOT NULL UNIQUE ); -- @@ -41,7 +45,6 @@ CREATE TABLE bf_eqs ( CREATE TABLE profiles ( id integer PRIMARY KEY AUTOINCREMENT, name text NOT NULL UNIQUE, - eula int DEFAULT 0, gender text, dob date, act_lvl int DEFAULT 2, -- [1, 2, 3, 4, 5] @@ -50,7 +53,6 @@ CREATE TABLE profiles ( bmr_eq_id int DEFAULT 1, bf_eq_id int DEFAULT 1, created int DEFAULT (strftime ('%s', 'now')), - -- last_active timestamp? FOREIGN KEY (bmr_eq_id) REFERENCES bmr_eqs (id) ON UPDATE CASCADE, FOREIGN KEY (bf_eq_id) REFERENCES bf_eqs (id) ON UPDATE CASCADE );