From e53d8ea4cba83045ba89de9ebc365f03340fecf6 Mon Sep 17 00:00:00 2001
From: archmans <13521010@std.stei.itb.ac.id>
Date: Wed, 5 Apr 2023 16:07:35 +0700
Subject: [PATCH] feat : latihan_program dan program

---
 src/tesBacaDB.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/src/tesBacaDB.py b/src/tesBacaDB.py
index 07463a6..8a9629b 100644
--- a/src/tesBacaDB.py
+++ b/src/tesBacaDB.py
@@ -36,9 +36,23 @@ cur.execute("""
             tot_duration integer
             )
             """)
+cur.execute("""
+            CREATE TABLE IF NOT EXISTS program (
+            program_id integer PRIMARY KEY AUTOINCREMENT,
+            title_program text
+            )
+            """)
+
+cur.execute("""
+            CREATE TABLE IF NOT EXISTS latihan_program (
+            program_id integer,
+            exercise_id integer,
+            FOREIGN KEY (program_id) REFERENCES program (program_id)
+            )
+            """)
 
 cur.execute("""
-            INSERT INTO daftar_latihan 
+            INSERT or IGNORE INTO daftar_latihan 
                 (exercise_id, title, description, goals, duration, repetition, gif)
             VALUES 
                 (201, 'Push Up', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ac venenatis purus. Nulla a fringilla ante. Aenean id ipsum pellentesque, convallis ex eget, cursus dolor','Goals', NULL, 10, '../img/push-up.gif'),
@@ -59,7 +73,48 @@ cur.execute("""
                 (108, "Russian Twist", "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ac venenatis purus. Nulla a fringilla ante. Aenean id ipsum pellentesque, convallis ex eget, cursus dolor", 'Goals', 30, NULL,"../img/")
             """)
 
+cur.execute("""
+            INSERT or IGNORE INTO program
+                (program_id, title_program)
+            VALUES
+                (1, 'Full Body Workout'),
+                (2, 'Upper Body Workout'),
+                (3, 'Lower Body Workout'),
+                (4, 'Core Workout')
+            """)
+
+cur.execute("""
+            INSERT or IGNORE INTO latihan_program
+                (program_id, exercise_id)
+            VALUES
+                (1, 201),
+                (1, 202),
+                (1, 203),
+                (1, 204),
+                (1, 205),
+                (1, 206),
+                (2, 207),
+                (2, 208),
+                (2, 201),
+                (2, 202),
+                (2, 203),
+                (2, 204),
+                (3, 205),
+                (3, 206),
+                (3, 207),
+                (3, 208),
+                (3, 201),
+                (3, 202),
+                (4, 203),
+                (4, 204),
+                (4, 205),
+                (4, 206),
+                (4, 207),
+                (4, 208)
+            """)
+
 con.commit()
+con.close()
 # cur.execute("""
 #             INSERT INTO daftar_request
 #                 (user_id, trainer_id, umur, jenis_kelamin, berat_badan, tinggi_badan, tujuan, status, title, description)
-- 
GitLab