def build_insert_query(table_name, column_datas):

    """
        Args:
            table: <str>
            column_datas: [
                {
                    "name": <str>
                    "insert_values": [
                        <int || str>,
                        ...
                    ]
                },
                ...
            ]
        Returns:
            insert_query: <str>
    """

    columns = []
    values = []

    # preset values inner arrays
    val_sets_length = min([ len(x['insert_values']) for x in column_datas ])
    for i in range(0, val_sets_length):
        values.append([])

    # build columns and values lists
    for column_data in column_datas:
        columns.append(column_data['name'])
        for i in range(0, val_sets_length):
            val = column_data['insert_values'][i]
            values[i].append(val)

    columns_str = '(' + ",".join(columns) + ')'
    # build values string
    values_str = []
    for val_list in values:
        val_set_str = []
        for v in val_list:
            if isinstance(v, str):
                val_set_str.append('"' + v + '"')
            else:
                val_set_str.append(str(v))
        values_str.append('(' + ','.join(val_set_str) + ')')
    values_str = ','.join(values_str)

    insert_query = """
        INSERT INTO {table_name}
            {columns_str}
        VALUES
            {values_str};
    """.format(
        table_name=table_name,
        columns_str=columns_str,
        values_str=values_str
    )

    return insert_query