# Import the pandas and requests libraries
import pandas as pd
import requests

# Read the data from an Excel file using Pandas
df = pd.read_excel('rules.xlsx')

# Loop over each row in the data
for index, row in df.iterrows():
    # Get the values for the current row
    title = row[0]
    description = row[1]
    tags = row[2]
    logsource = row[3]

    # Construct a URL with the current row's values as parameters
    url = f'http://localhost:5104/insert?title={title}&description={description}&tags={tags}&logsource={logsource}'

    # Send a GET request to the local URL
    response = requests.get(url)

    # Check the response status code to see if the insertion was successful
    if response.status_code == 200:
        print(f'Successfully inserted row {index}')
    else:
        # Print an error message if the insertion failed
        print(f'Error inserting row {index}: {response.text}')
