in reply to Re^2: Combining Ffile:fetch with MySQL
in thread Combining Ffile:fetch with MySQL
A wild guess and some untested example code would be:
Instead of printing the link, you would use your code to download that doc, then do whatever you are going to do with it.
Update: I see that you are using MySQL instead of SQLite. Brain cramp on my part. But code is essentially the same - just a difference in how to get the DB connection. The dbi would be: dbi::MySQL, then you need an account and password. For SQLite, these are null strings. See the doc's referenced above for a connection example with username/password.
I can't anticipate exactly what kind of SQL you need. Above just gets docs for a particular date. Although sounds like what you need is: for each unique id, download latest version of the document. The SQL for that is of course more involved but doable.#!/usr/bin/perl use warnings; use strict; use Data::Dumper; use DBI qw(:sql_types); my $dbfile = "./YourDbName.sqlite"; my $dbh = DBI->connect("dbi:SQLite:dbname=$dbfile","","",{RaiseError = +> 1}) or die "Couldn't connect to database: " . DBI->errstr; my $get_links_4date_sql = "SELECT Identifer, LINK FROM YourTableName WHERE Publish date IS ?"); my $get_links_4date = $dbh->prepare ($get_links_4date_sql); my $date = "20220701"; $get_links_4date->execute($date); my $array_ref = $get_links_4date->fetchall_arrayref; foreach my $row_ref (@$array_ref) { my ($id,$link) = @$row_ref; print "$id \t $link\n"; }
Hope this gets you further along your way.
|
|---|