in reply to Save MP3 Tag's to Database with SPOPS
package DBH; use strict; use DBIx; use constant DBI_DSN => 'DBI:vendor:database:host'; use constant DBI_USER => 'user'; use constant DBI_PASS => 'pass'; my $DBH; sub import { unless (ref $DBH) { $DBH = DBI->connect( DBI_DSN, DBI_USER, DBI_PASS, {RaiseError => 1} ); } $DBIx::DBH = $DBH; } 1; package main; use DBH; # creates database handle via import() ### initialize + config code un-necessary ### not with SQL::Catalog + DBIx ### and not, as mentioned in the conclusion ### with DBIx::Recordset ### and probably not Alzabo either find sub { return unless m/\.mp3$/; my $tag = get_mp3tag($_) or return; my %tag = %$tag; # sql_do finds the $dbh for you... sql_do sql_lookup 'insert_mp3_tag_data', @tag{title artist album year genre} ; }, @ARGV;
Also, consider that your entire example would be a DBIx::Recordset one-liner. I think I will contact Dave Rolsky and coax him into posting an Alzabo version. Then every person who is actively working on database frameworks will have an example here.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: SPOPS compared with Alzabo
by autarch (Hermit) on Jan 09, 2002 at 00:40 UTC | |
by princepawn (Parson) on Jan 09, 2002 at 22:47 UTC | |
Re: SPOPS compared with SQL::Catalog + DBIx
by lachoy (Parson) on Jan 08, 2002 at 17:58 UTC |