def LogSQL(filename, CN, sql):
    """
    Appends to given log file the sql executed with this format:
    -----------------------------------
    --Server:   SERVERNAME
    --Database: DATABASE
    script line 1
    script line 2
    ...
    -----------------------------------
    """

    today = str(datetime.date.today())
    f = open(filename, 'a')
    s = "\n\n-----------------------------------------------------\n\n"
    s = s + '--Server:   ' + CN['servername'] + "\n"
    s = s + '--Database: ' + CN['db'] + "\n"
    s = s + '--Date:     ' + today + "\n\n"
    s = s + sql
    s = s + "\n\n-----------------------------------------------------\n\n"
    f.write(s)
    f.close()

    Appends to given log file the sql executed with this format:
    -----------------------------------
    --Server:   SERVERNAME
    --Database: DATABASE
    script line 1
    script line 2
    ...
    -----------------------------------
    
recipes/Python/579023_Python_SQLSMO__Threading_Example/recipe-579023.py