insert list of dictionaries into database tables

    **Key Arguments:**
        - ``dbConn`` -- mysql database connection
        - ``log`` -- logger
        - ``dictList`` -- list of python dictionaries to add to the database table
        - ``dbTableName`` -- name of the database table
        - ``uniqueKeyList`` -- a list of column names to append as a unique constraint on the database
        - ``dateModified`` -- add the modification date as a column in the database
        - ``dateCreated`` -- add the created date as a column in the database
        - ``batchSize`` -- batch the insert commands into *batchSize* batches
        - ``replace`` -- repalce row if a duplicate is found
        - ``dbSettings`` -- pass in the database settings so multiprocessing can establish one connection per process (might not be faster)

    **Return:**
        - None

    **Usage:**

        .. code-block:: python

            from fundamentals.mysql import insert_list_of_dictionaries_into_database_tables
            insert_list_of_dictionaries_into_database_tables(
                dbConn=dbConn,
                log=log,
                dictList=dictList,
                dbTableName="test_insert_many",
                uniqueKeyList=["col1", "col3"],
                dateModified=False,
                batchSize=2500
            )

def insert_list_of_dictionaries_into_database_tables(
        dbConn,
        log,
        dictList,
        dbTableName,
        uniqueKeyList=[],
        dateModified=False,
        dateCreated=True,
        batchSize=2500,
        replace=False,
        dbSettings=False):
    """insert list of dictionaries into database tables

    **Key Arguments:**
        - ``dbConn`` -- mysql database connection
        - ``log`` -- logger
        - ``dictList`` -- list of python dictionaries to add to the database table
        - ``dbTableName`` -- name of the database table
        - ``uniqueKeyList`` -- a list of column names to append as a unique constraint on the database
        - ``dateModified`` -- add the modification date as a column in the database
        - ``dateCreated`` -- add the created date as a column in the database
        - ``batchSize`` -- batch the insert commands into *batchSize* batches
        - ``replace`` -- repalce row if a duplicate is found
        - ``dbSettings`` -- pass in the database settings so multiprocessing can establish one connection per process (might not be faster)

    **Return:**
        - None

    **Usage:**

        .. code-block:: python

            from fundamentals.mysql import insert_list_of_dictionaries_into_database_tables
            insert_list_of_dictionaries_into_database_tables(
                dbConn=dbConn,
                log=log,
                dictList=dictList,
                dbTableName="test_insert_many",
                uniqueKeyList=["col1", "col3"],
                dateModified=False,
                batchSize=2500
            )
    """

    log.debug(
        'completed the ````insert_list_of_dictionaries_into_database_tables`` function')

    global count
    global totalCount
    global globalDbConn
    global sharedList

    reDate = re.compile('^[0-9]{4}-[0-9]{2}-[0-9]{2}T')

    if dbSettings:
        globalDbConn = dbSettings
    else:
        globalDbConn = dbConn

    if len(dictList) == 0:
        log.warning(
            'the dictionary to be added to the database is empty' % locals())
        return None

    if len(dictList):
        convert_dictionary_to_mysql_table(
            dbConn=dbConn,
            log=log,
            dictionary=dictList[0],
            dbTableName=dbTableName,
            uniqueKeyList=uniqueKeyList,
            dateModified=dateModified,
            reDatetime=reDate,
            replace=replace,
            dateCreated=dateCreated)
        dictList = dictList[1:]

    dbConn.autocommit(False)

    if len(dictList):

        total = len(dictList)
        batches = int(total / batchSize)

        start = 0
        end = 0
        sharedList = []
        for i in range(batches + 1):
            end = end + batchSize
            start = i * batchSize
            thisBatch = dictList[start:end]
            sharedList.append((thisBatch, end))

        totalCount = total + 1
        ltotalCount = totalCount

        print "Starting to insert %(ltotalCount)s rows into %(dbTableName)s" % locals()

        print dbSettings

        if dbSettings == False:

            fmultiprocess(
                log=log,
                function=_insert_single_batch_into_database,
                inputArray=range(len(sharedList)),
                dbTableName=dbTableName,
                uniqueKeyList=uniqueKeyList,
                dateModified=dateModified,
                replace=replace,
                batchSize=batchSize,
                reDatetime=reDate,
                dateCreated=dateCreated
            )

        else:
            fmultiprocess(log=log, function=_add_dictlist_to_database_via_load_in_file,
                          inputArray=range(len(sharedList)), dbTablename=dbTableName,
                          dbSettings=dbSettings, dateModified=dateModified)

        sys.stdout.write("\x1b[1A\x1b[2K")
        print "%(ltotalCount)s / %(ltotalCount)s rows inserted into %(dbTableName)s" % locals()

    log.debug(
        'completed the ``insert_list_of_dictionaries_into_database_tables`` function')
    return None