from script_config import *
import pandas as pd
from CriteoPy import AXDBTools, AXOutTools

if kind_of_query != 'vertica':
    raise NotImplementedError("This kind of query hasn't been implemented yet.")

oAXD = AXDBTools()
connection = oAXD.GetoDbh()

# read the query
with open('query.sql', 'r') as f:
    query = f.read()

# run the query
results = pd.read_sql(query, connection)

# assign the filename for the output
filename = 'output_file'

# write the results to a file
if output_type == 'csv':
    filename += '.csv'
    results.to_csv(filename, index=False)

elif output_type == 'excel':
    filename += '.xlsx'
    results.to_excel(filename, index=False)

# send an email with the report
email = AXOutTools()

email_args = {
    'sTo': [destination_email],
    'sFrom': email_sender,
    'sSubject': email_subject,
    'sBody': email_body,
    'aAttachments': [filename]
}

email.SendEmail(email_args)