in reply to Re: Combining Ffile:fetch with MySQL
in thread Combining Ffile:fetch with MySQL
ok, here is the code I put together from the really helpful response. it runs with no errors, it just doesn't download... I must be missing something.
$host = "localhost"; $port = "3306"; $dbdriver='mysql'; $tablename = "linktable"; print "Enter year and month to download in format YYYYMM:"; $date = <STDIN>; chomp $date; $dsn = "dbi:$dbdriver:$database:$host:$port"; $path='/data/'; my $dbh = DBI->connect($dsn, $user, $password) or die "Couldn't connect to database: " . DBI->errstr; $dbh-> do("DROP TABLE IF EXISTS LINKTABLE"); $dbh-> do("CREATE TABLE IF NOT EXISTS LINKTABLE(document_id CHAR(9),IN +DEX(DOCUMENT_ID),PUBLISH_DATE CHAR(8),URL CHAR(150))"); $dbh-> do("LOAD DATA LOCAL INFILE '/data/DATA.CSV' INTO TABLE $tablena +me(DOCUMENT_ID,PUBLISH_DATE)"); $dbh-> do("UPDATE LINKTABLE SET URL=CONCAT('www.example.com/document/' +,DOCUMENT_ID,'document.pdf')") ; my $SQL = "select url,document_id FROM $tablename where left(publish_d +ate,6) ='$date'"; my $query = $dbh->prepare($SQL) or die "prepare: ".$dbh->errstr; $query-> execute() or die "execute: ".$dbh->errstr; while ($url,$document_id = $query->fetchrow_array()) { print "url: $row->{url} \n"; my $outfile = '$path.$document_id'; my $ff = File::Fetch->new( uri => url ); $ff->fetch(to => $outfile) or die "failed to fetch '$url' to '$outf +ile'."; #rename("document.pdf","/output/$document_id.pdf") || die "Can't re +name file: ";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Combining Ffile:fetch with MySQL
by hippo (Archbishop) on Jul 24, 2022 at 09:29 UTC | |
by afoken (Chancellor) on Jul 24, 2022 at 10:13 UTC | |
by justin423 (Scribe) on Jul 24, 2022 at 15:28 UTC | |
by justin423 (Scribe) on Jul 24, 2022 at 17:48 UTC | |
by hippo (Archbishop) on Jul 24, 2022 at 22:34 UTC | |
by justin423 (Scribe) on Jul 24, 2022 at 23:13 UTC | |
|