From: gamesguru Date: Mon, 31 May 2021 19:48:51 +0000 (-0400) Subject: update readme, shell fixes from pycharm, comment last_sync funcs X-Git-Tag: 0.0.4~4 X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=636378c522b6fb1d4b73865e82c9cec9676850cd;p=nutratech%2Fnt-sqlite.git update readme, shell fixes from pycharm, comment last_sync funcs --- diff --git a/README.rst b/README.rst index 0eedc76..dbe4c8f 100644 --- a/README.rst +++ b/README.rst @@ -18,8 +18,7 @@ Building the database .. code-block:: bash - cd sql - bash build.sh + python build.py 3. Verify the tables (again inside the SQL shell :code:`sqlite nutra.db`), diff --git a/sql/__init__.py b/sql/__init__.py index 77776ac..f256826 100644 --- a/sql/__init__.py +++ b/sql/__init__.py @@ -5,7 +5,6 @@ import csv import os import sqlite3 -# TODO: defined-twice, from ntclient import NT_DB_NAME NT_DB_NAME = "nt.sqlite" SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/sql/export.sh b/sql/export.sh index 627d8d8..7cd49c9 100755 --- a/sql/export.sh +++ b/sql/export.sh @@ -3,12 +3,13 @@ cd "$(dirname "$0")" table_cmd="sqlite3 nt.sqlite '.tables'" -tables=`sqlite3 nt.sqlite '.tables'` +tables=$(bash -exec "$table_cmd") +echo "$tables" for t in $tables do export_cmd="SELECT * FROM $t" - echo $export_cmd + echo "\"$export_cmd\"" export_cmd="sqlite3 -csv nt.sqlite "\"$export_cmd\""" bash -exec "$export_cmd" > "data/$t.csv" done diff --git a/sql/format.sh b/sql/format.sh index 0c90d08..47de684 100755 --- a/sql/format.sh +++ b/sql/format.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e cd "$(dirname "$0")" diff --git a/sql/functions.sql b/sql/functions.sql index 5574dd3..dda9dbc 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -170,18 +170,18 @@ GROUP BY -- Last sync -------------------------------- -SELECT - max(( - SELECT - last_sync FROM profiles), ( - SELECT - last_sync FROM biometric_log), ( - SELECT - last_sync FROM recipes), ( - SELECT - last_sync FROM food_log), ( - SELECT - last_sync FROM recipe_log), ( - SELECT - last_sync FROM rda)) AS last_sync; +-- SELECT +-- max(( +-- SELECT +-- last_sync FROM profiles), ( +-- SELECT +-- last_sync FROM biometric_log), ( +-- SELECT +-- last_sync FROM recipes), ( +-- SELECT +-- last_sync FROM food_log), ( +-- SELECT +-- last_sync FROM recipe_log), ( +-- SELECT +-- last_sync FROM rda)) AS last_sync;