Commit 8d03aea2 authored by salma's avatar salma

move reset any part of the db option to the env vars for better control

parent 754e2486
import psycopg2 import psycopg2
import os import os
import sys
schema_sql = """ schema_sql = """
-- Create students table -- Create students table
...@@ -113,8 +114,9 @@ def setup_database(drop_existing_tables: bool = False): ...@@ -113,8 +114,9 @@ def setup_database(drop_existing_tables: bool = False):
if __name__ == "__main__": if __name__ == "__main__":
# To run with a clean slate, pass True _drop_env = os.getenv("DROP_TEST_SCHEMA", "False")
#setup_database(drop_existing_tables=True) drop_existing_tables = str(_drop_env).strip().lower() in ("1", "true", "yes", "y", "t")
print("**************************************************")
# To run without dropping tables (default) print(f"Drop existing tables: {drop_existing_tables}")
setup_database() print("**************************************************")
\ No newline at end of file setup_database(drop_existing_tables=drop_existing_tables)
\ No newline at end of file
...@@ -261,8 +261,14 @@ if __name__ == "__main__": ...@@ -261,8 +261,14 @@ if __name__ == "__main__":
# Path to the JSON file # Path to the JSON file
json_file_path = "All_Curriculums_grouped.json" json_file_path = "All_Curriculums_grouped.json"
# Read DROP_CURRICULUM_STRUCTURE from env and set drop_existing_table accordingly
_drop_val = os.getenv("DROP_CURRICULUM_STRUCTURE", "").strip().lower()
drop_existing_table = _drop_val in ("1", "true", "yes", "y")
print("**************************************************")
print(f"Drop existing table: {drop_existing_table}")
print("**************************************************")
# Setup curriculum database with JSON data # Setup curriculum database with JSON data
setup_curriculum_database(json_file_path, drop_existing_table=False) setup_curriculum_database(json_file_path, drop_existing_table=drop_existing_table)
print("\n" + "=" * 60) print("\n" + "=" * 60)
print("🔍 Verifying Setup") print("🔍 Verifying Setup")
......
...@@ -197,8 +197,9 @@ def setup_embeddings_database(drop_existing_tables: bool = False): ...@@ -197,8 +197,9 @@ def setup_embeddings_database(drop_existing_tables: bool = False):
print("Database connection closed.") print("Database connection closed.")
if __name__ == "__main__": if __name__ == "__main__":
# To run with a clean slate, pass True drop_env = os.getenv("DROP_TABLE_EMBEDDINGS", "false")
# setup_embeddings_database(drop_existing_tables=True) drop_existing = str(drop_env).strip().lower() in ("1", "true", "yes")
print("**************************************************")
# To run without dropping the table (default) print(f"Drop existing table: {drop_existing}")
setup_embeddings_database() print("**************************************************")
\ No newline at end of file setup_embeddings_database(drop_existing_tables=drop_existing)
...@@ -74,4 +74,9 @@ def setup_mcq_table(drop_existing_table: bool = False): ...@@ -74,4 +74,9 @@ def setup_mcq_table(drop_existing_table: bool = False):
if __name__ == "__main__": if __name__ == "__main__":
print("Setting up the MCQ table structure...") print("Setting up the MCQ table structure...")
setup_mcq_table(drop_existing_table=False) drop_env = os.getenv("DROP_MCQ_TABLE", "false")
\ No newline at end of file drop_existing_table = str(drop_env).strip().lower() in ("1", "true", "yes")
print("**************************************************")
print(f"Drop existing table: {drop_existing_table}")
print("**************************************************")
setup_mcq_table(drop_existing_table=drop_existing_table)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment