Untitled

 avatar
unknown
plain_text
a month ago
990 B
4
Indexable
if len(sys.argv) != 3:
    print("Usage: python gen_trig_fk_v1.py <sql_file> <schema_name>")
    sys.exit(1)

# Get SQL file path and create CSV filename
sql_file = datdir + '/' + sys.argv[1]
schema_name = sys.argv[2].upper()
csv_filename = sql_file.replace('.sql', '.csv')

# Connect to database and generate CSV
connection = get_db_connection()
if connection is None:
    printf("Failed to connect to database. Exiting.")
    sys.exit(1)

# Read and modify SQL
modified_sql = read_and_modify_sql(sql_file, schema_name)
if modified_sql is None:
    printf("Failed to read/modify SQL file. Exiting.")
    connection.close()
    sys.exit(1)

# Execute modified SQL and create CSV
if not execute_sql_to_csv(connection, modified_sql, csv_filename):
    printf("Failed to create CSV from SQL. Exiting.")
    connection.close()
    sys.exit(1)

connection.close()

# Now use the generated CSV file for the rest of the process
triggerDetail_filename = csv_filename
validation_schema = schema_name
Leave a Comment