def insertMany(dbCursor, table, dataDict, arrayFields, scalarFields=None):
    """Insert multiple rows into the specified table of a database.
    Should raise an exception if it fails--does it do so reliably?
    
    Inputs:
    - dbCursor: database cursor
    - table: name of table
    - dataDict: dict of field name: value entries
    - arrayFields: a list of fields to add whose values are arrays;
        every array must have the same length;
        one row will be added for each array element
    - scalarFields: a list of fields to add whose values are scalars;
        these fields will have the same value for every added row
        
    Returns the number of rows added.
    """
    scalarFields = scalarFields or []
    numEntries = 0
    for fieldName in arrayFields:
        if numEntries:
            if len(dataDict[fieldName]) != numEntries:
                raise ValueError('arrays must have matching length')
        else:
            numEntries = len(dataDict[fieldName])
    if numEntries == 0:
        return 0
    listOfLists = [([dataDict[fieldName]] * numEntries) for fieldName in
        scalarFields] + [dataDict[fieldName] for fieldName in arrayFields]
    zippedList = zip(*listOfLists)
    allFields = scalarFields + arrayFields
    fieldListStr = ', '.join(allFields)
    sArry = ('%s, ' * len(allFields))[:-2]
    sqlCmd = 'insert into %s (%s) values (%s)' % (table, fieldListStr, sArry)
    dbCursor.executemany(sqlCmd, zippedList)
    return numEntries
