On Mar 20, 2006, at 5:50 PM, Daniel Macks wrote:
In order to 'fink list', the only things you need are the pure perl
parts...don't need a full local fink installation or compiled dpkg and
other support binaries. Until recently, the web PDB database update
script was running on a linux box on which we did not have root
access.
Good point!
Perhaps someone could add a cron to PDB that just dumps the MySQL
database to a .bz2 file daily? Or the regular PDB process could dump
that file?
Seems reasonable (and generally useful too)...the update is driven by
cron, so it'd be easy to dump the whole db after updating it. Here's
"mysqldump" of the "package" database:
http://pdb.finkproject.org/pdb/full_dump_2006-03-20_23:35.sql.bz2
Is that what you need?
Wow, it's huge. Yes, it will do fine, unless you are worried about
the bandwidth usage. Hopefully it will be a rarely accessed file.
I don't know much about mysqldump, but I do know that our databases
are password-protected. Is there a way to have mysqldump read the
password from a file so we don't have to hard-code it in Yet Another
Place in our scripts? Alternately, is there a way to do the dump using
mysql commands (since we already have a generic way to "run mysql
commands using the password")?
You could easily parse the password out of your PHP file like so:
#!/bin/csh
set file = "db.inc.php"
set out = "packages.sql.bz2"
set db_name = `perl -0 -ne'/\$db_name\s*=\s*\"([^\"]+)/&&print $1'
$file`
set db_user = `perl -0 -ne'/\$db_user\s*=\s*\"([^\"]+)/&&print $1'
$file`
set db_passwd = `perl -0 -ne'/\$db_passwd\s*=\s*\"([^\"]+)/&&print
$1' $file`
mysqldump -u $db_user -p$db_passwd $db_name packages | bzip2 >! $out
Alternatively, making a CSV file is pretty easy in Perl, even by hand:
use DBI;
my %dbvars;
# Parse DB info out of the PHP file
open my $fh, '<', 'db.inc.php' or die;
while (<$fh>) {
if (/\$db_(name|user|passwd)\s*=\s*[\'\"]([^\'\"]+)/) {
$dbvars{$1} = $2;
}
}
close $fh;
# Dump the database to comma-separated fields
my $dbh = DBI->connect("DBI:mysql:database=$dbvars{name}",
$dbvars{user}, $dbvars{passwd});
my $sth = $dbh->prepare('select * from packages');
$sth->execute();
# Print header row first
print join(',', map {$dbh->quote($_)} @{$sth->{NAME}}), "\n";
while (my $row = $sth->fetchrow_arrayref) {
print join(',', map {$dbh->quote($_)} @$row), "\n";
}
An even cooler alternative would be an SQLite file that I could
download. If that's appealing, I would be quite happy to write an
exporter for you.
Chris
--
Chris Dolan, Software Developer, Clotho Advanced Media Inc.
608-294-7900, fax 294-7025, 1435 E Main St, Madison WI 53703
vCard: http://www.chrisdolan.net/ChrisDolan.vcf
Clotho Advanced Media, Inc. - Creators of MediaLandscape Software
(http://www.media-landscape.com/) and partners in the revolutionary
Croquet project (http://www.opencroquet.org/)
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Fink-devel mailing list
Fink-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fink-devel