def ActionParsing(DBLIST2):
    """
    Executes the actions from the source file, passed as the DBLIST2 array
    """
    f = DBLIST2.pop()


    DESTSERVER = f[0]
    SOURCEDB = f[1]
    BACKUPFOLDER = f[2]
    DATAFOLDER = f[3]
    LOGFOLDER = f[4]
    DESTDB = f[5]
    ACTIONS = f[6]

    # open actions file, column 6
    action_list = []
    with open(ACTIONS, newline='') as g:
        action_l = g.readlines()
    for y in action_l:
        if y[0] != '#':
            action_list.append(y)

    CONNECTION = {}
    CONNECTION['servername'] = DESTSERVER
    CONNECTION['username'] = ''
    CONNECTION['password'] = ''
    CONNECTION['db'] = DESTDB


    msg = "\n"
    SQL = "\n"

    for m in action_list:
        m = m.strip()

        if m == 'BACKUP DATABASE FULL':
            # print('testing full backup')
            DB_BACKUP = BACKUPFOLDER + '\\' + DESTDB + '_backup_' + DatedString() + '.BAK'
            #database to backup is DESTDB
            smobackup = SQLSMO(CONNECTION, '', '', DB_BACKUP)
            smobackup.BackupDatabase()
            msg = msg + ' action:' + m + "\n"
            SQL = SQL + smobackup.sqlbackup + "\n\n"
            # msg = msg + " SQL: \n" + smobackup.sqlbackup + "\n"

        elif m == 'RESTORE DATABASE':
            try:
                BKFILE = GetLatestBackup(BACKUPFOLDER, '\\' + SOURCEDB + BACKUP_MASK)[-1]
            except IndexError:
                print('No backup file!')
                break

            smo3 = SQLSMO(CONNECTION, DATAFOLDER, LOGFOLDER, BKFILE)
            smo3.noexecute = NOEXECUTE_OPTION
            ok_to_restore = smo3.Ok_to_restore()
            if ok_to_restore == True:
                confirm_msg = 'Ok to restore'
            else:
                confirm_msg = 'NOT ok to restore'
                smo3.noexecute = 0

            smo3.RestoreDatabase()

            msg = msg + ' action:' + m + "\n"
            msg = msg + confirm_msg + "\n"
            SQL = SQL + smo3.sqlrestore + "\n\n"
            # msg = msg + " SQL: \n" + smo3.sqlrestore + "\n"
        elif m == 'KILL CONNECTIONS':
            r = KillConnections(CONNECTION, DESTDB)
            msg = msg + ' action:' + m + "\n"
            msg = msg + str(r) + "\n"
        elif m == 'SET DBOWNER: sa':
            s = 'USE [' + DESTDB + '] EXEC dbo.sp_changedbowner @loginame = N' + chr(39)+ 'sa' + chr(39) + ', @map = false'
            try:
                rows, fnames = SqlExecute(CONNECTION, s)
            except Exception as inst:
                print('Error executing set dbwoner sa: ', inst)
            msg = msg + ' action:' + m + "\n"
            SQL = SQL + s + "\n\n"
            # msg = msg + " SQL: \n" + s + "\n"
        elif m == 'SYNC LOGINS':
            rows = SyncLogins(CONNECTION, DESTDB)
            msg = msg + ' action:' + m + "\n"
            for y in rows:
                msg = msg + str(y) + "\n"
        elif m == 'SET SIMPLE MODE':
            s = 'USE [master] ALTER DATABASE [' + DESTDB + '] SET RECOVERY SIMPLE WITH NO_WAIT'
            try:
                rows, fnames = SqlExecute(CONNECTION, s)
            except Exception as inst:
                print('Error executing set simple mode ', inst)
            msg = msg + ' action:' + m + "\n"
            SQL = SQL + s + "\n\n"
            # msg = msg + " SQL: \n" + s + "\n"
        elif m == 'SHRINK LOG':
            s = '''
            declare @logfilename varchar(200)
            select @logfilename = name  from sysfiles where groupid = 0
            DBCC SHRINKFILE (@logfilename , 0, TRUNCATEONLY)
            '''
            s = 'USE [' + DESTDB + '] ' + s
            try:
                rows, fnames = SqlExecute(CONNECTION, s)
            except Exception as inst:
                print('Error executing shrink log ', inst)
            msg = msg + ' action:' + m + "\n"
            SQL = SQL + s + "\n\n"
            # msg = msg +  " SQL: \n" + s + "\n"
    with lock:
        print(msg)
        print(f)
        LogSQL('SqlScripts.sql', CONNECTION, SQL)
    return f

    Executes the actions from the source file, passed as the DBLIST2 array
    
recipes/Python/579023_Python_SQLSMO__Threading_Example/recipe-579023.py