Untitled

 avatar
unknown
plain_text
a month ago
626 B
3
Indexable
# Modify the main input section
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]
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)

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