From: gamesguru Date: Tue, 9 Mar 2021 19:04:14 +0000 (-0500) Subject: details X-Git-Tag: 0.0.1~12 X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=37417a9d468887c958aa304db75e8786651b4fed;p=nutratech%2Fnt-sqlite.git details --- diff --git a/.gitignore b/.gitignore index a757062..a4e0d32 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,6 @@ ._* .DS_Store -# database files -*.db -*.sqlite +# Database files +*.sqlite* + diff --git a/sql/build.py b/sql/build.py index a0673dd..1cd54b2 100755 --- a/sql/build.py +++ b/sql/build.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import csv import os import sqlite3 @@ -14,9 +15,12 @@ def main(): print("\nPack nt.sqlite") con = sqlite3.connect("nt.sqlite") cur = con.cursor() + + print("\n-> Create tables") with open("tables.sql") as tables: cur.executescript(tables.read()) + print("-> Populate data") for p in os.listdir("data"): if not p.endswith(".csv"): continue diff --git a/sql/import.sql b/sql/import.sql deleted file mode 100644 index 19c7a18..0000000 --- a/sql/import.sql +++ /dev/null @@ -1,42 +0,0 @@ --- nt-sqlite, an sqlite3 database for nutratracker clients --- Copyright (C) 2020 Shane Jaroch --- --- This program is free software: you can redistribute it and/or modify --- it under the terms of the GNU General Public License as published by --- the Free Software Foundation, either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . - -PRAGMA foreign_keys = 1; --- PRAGMA integrity_check = 1; - - -.mode csv --- .nullvalue NULL - -.import '| tail -n +2 ./data/bmr_eqs.csv' bmr_eqs -.import '| tail -n +2 ./data/bf_eqs.csv' bf_eqs -.import '| tail -n +2 ./data/meals.csv' meals - -.import '| tail -n +2 ./data/biometrics.csv' biometrics -.import '| tail -n +2 ./data/profiles.csv' profiles -.import '| tail -n +2 ./data/rda.csv' rda - -.import '| tail -n +2 ./data/recipes.csv' recipes -.import '| tail -n +2 ./data/recipe_dat.csv' recipe_dat - -.import '| tail -n +2 ./data/food_log.csv' food_log -.import '| tail -n +2 ./data/recipe_log.csv' recipe_log - -.import '| tail -n +2 ./data/biometric_log.csv' biometric_log -.import '| tail -n +2 ./data/bio_log_entry.csv' bio_log_entry - -.header on -.mode column diff --git a/sql/init.sql b/sql/init.sql deleted file mode 100644 index 9039d81..0000000 --- a/sql/init.sql +++ /dev/null @@ -1,2 +0,0 @@ -.read tables.sql -.read import.sql diff --git a/sql/tables.sql b/sql/tables.sql index a8afd35..8414f5c 100644 --- a/sql/tables.sql +++ b/sql/tables.sql @@ -17,9 +17,6 @@ CREATE TABLE version( id integer PRIMARY KEY AUTOINCREMENT, version text NOT NULL, created date NOT NULL, notes text ); -INSERT INTO version(version, created, notes) - VALUES ('0.0.0', '2020-09-22', 'initial release'); - -- --------------------------------- -- Equations