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 os
import sys
schema_sql = """
-- Create students table
......@@ -113,8 +114,9 @@ def setup_database(drop_existing_tables: bool = False):
if __name__ == "__main__":
# To run with a clean slate, pass True
#setup_database(drop_existing_tables=True)
# To run without dropping tables (default)
setup_database()
\ No newline at end of file
_drop_env = os.getenv("DROP_TEST_SCHEMA", "False")
drop_existing_tables = str(_drop_env).strip().lower() in ("1", "true", "yes", "y", "t")
print("**************************************************")
print(f"Drop existing tables: {drop_existing_tables}")
print("**************************************************")
setup_database(drop_existing_tables=drop_existing_tables)
\ No newline at end of file
......@@ -261,8 +261,14 @@ if __name__ == "__main__":
# Path to the JSON file
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(json_file_path, drop_existing_table=False)
setup_curriculum_database(json_file_path, drop_existing_table=drop_existing_table)
print("\n" + "=" * 60)
print("🔍 Verifying Setup")
......
......@@ -197,8 +197,9 @@ def setup_embeddings_database(drop_existing_tables: bool = False):
print("Database connection closed.")
if __name__ == "__main__":
# To run with a clean slate, pass True
# setup_embeddings_database(drop_existing_tables=True)
# To run without dropping the table (default)
setup_embeddings_database()
\ No newline at end of file
drop_env = os.getenv("DROP_TABLE_EMBEDDINGS", "false")
drop_existing = str(drop_env).strip().lower() in ("1", "true", "yes")
print("**************************************************")
print(f"Drop existing table: {drop_existing}")
print("**************************************************")
setup_embeddings_database(drop_existing_tables=drop_existing)
......@@ -74,4 +74,9 @@ def setup_mcq_table(drop_existing_table: bool = False):
if __name__ == "__main__":
print("Setting up the MCQ table structure...")
setup_mcq_table(drop_existing_table=False)
\ No newline at end of file
drop_env = os.getenv("DROP_MCQ_TABLE", "false")
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