How to prevent writing duplicate loops?

Move the control structure outside the template file and just put the repeatable markup and template tags inside.

$event_query = new WP_query($args);
if( $event_query->have_posts() ){
    while( $event_query->have_posts() ){
        $event_query->the_post();
        get_template_part('loop', 'home');
    }
}
wp_reset_postdata();

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)