#!/usr/bin/perl use strict; use warnings; use DBI; use Text::CSV; my $sth; my $input="main_table.csv"; my $csv=Text::CSV->new(); open(INFILE,$input) || die "Can't open file $input"; ##Start database connections############### my $database = "database"; my $db_server = "localhost"; my $user = "user"; my $password = "password"; my $dbh = DBI->connect("DBI:mysql:$database:$db_server", $user, $password); my $statement = "INSERT INTO table (state, city, location) VALUES (?,?,?)"; $sth = $dbh->prepare($statement) or die "Couldn't prepare the query: $sth->errstr"; while() { # I'm not sure where to go from here, need to put CSV fields into variables in SQL code? $sth->execute($state,$city,$location) or die "Couldn't execute query: $dbh->errstr"; } $sth->finish; $dbh->disconnect; close(INFILE);