Changeset 34 in mp3-find
- Timestamp:
- 05/22/06 18:25:32 (19 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Changes
r25 r34 1 1 Revision history for Perl extension MP3::Find. 2 3 0.06 4 - deprecated the create_db, update_db, and sync_db methods 5 - databases can be selected by a custom DSN or an already open database handle 2 6 3 7 0.05 28 Apr 2006 -
trunk/MANIFEST
r18 r34 6 6 t/02-filesystem.t 7 7 t/03-db.t 8 t/04-new-db.t 8 9 t/mp3s/not-an-mp3 9 10 t/mp3s/dont_look_here/testv2.4.0.mp3 -
trunk/lib/MP3/Find/DB.pm
r33 r34 72 72 73 73 # create another database 74 $finder->create_db('my_mp3s.db'); 75 76 # update the database from the filesystem 77 $finder->update_db('my_mp3s.db', ['/home/peter/mp3', '/home/peter/cds']); 74 $finder->create({ db_file => 'my_mp3s.db' }); 75 76 # update the database by searching the filesystem 77 $finder->update({ 78 db_file => 'my_mp3s.db', 79 dirs => ['/home/peter/mp3', '/home/peter/cds'], 80 }); 81 82 # or just update specific mp3s 83 $finder->update({ 84 db_file => 'my_mp3s.db', 85 files => \@filenames, 86 }); 78 87 79 88 # and then blow it away … … 86 95 =head1 DESCRIPTION 87 96 88 This is the SQLite database backend for L<MP3::Find>. 89 90 B<Note:> I'm still working out some kinks in here, so this backend 91 is currently not as stable as the Filesystem backend. 92 93 =head2 Special Options 94 95 =over 96 97 =item C<db_file> 98 99 The name of the SQLite database file to use. Defaults to F<~/mp3.db>. 100 101 The database should have at least one table named C<mp3> with the 102 following schema: 97 This is the database backend for L<MP3::Find>. The easiest way to 98 use it is with a SQLite database, but you can also pass in your own 99 DSN or database handle. 100 101 The database you use should have at least one table named C<mp3> with 102 the following schema: 103 103 104 104 CREATE TABLE mp3 ( … … 133 133 ); 134 134 135 B<Note:> I'm still working out some kinks in here, so this backend 136 is currently not as stable as the Filesystem backend. Expect API 137 fluctuations for now. 138 139 B<Deprecated Methods:> C<create_db>, C<update_db>, and C<sync_db> 140 have been deprectaed in this release, and will be removed in a future 141 release. PLease switch to the new methods C<create>, C<update>, and 142 C<sync>. 143 144 =head2 Special Options 145 146 When using this backend, provide one of the following additional options 147 to the C<search> method: 148 149 =over 150 151 =item C<dsn>, C<username>, C<password> 152 153 A custom DSN and (optional) username and password. This gets passed 154 to the C<connect> method of L<DBI>. 155 156 =item C<dbh> 157 158 An already created L<DBI> database handle object. 159 160 =item C<db_file> 161 162 The name of the SQLite database file to use. 163 135 164 =back 136 165 137 166 =cut 138 167 168 # get a database handle from named arguments 139 169 sub _get_dbh { 140 170 my $args = shift; 171 172 # we got an explicit $dbh object 141 173 return $args->{dbh} if defined $args->{dbh}; 174 175 # or a custom DSN 142 176 if (defined $args->{dsn}) { 143 177 my $dbh = DBI->connect( … … 149 183 return $dbh; 150 184 } 185 151 186 # default to a SQLite database 152 187 if (defined $args->{db_file}) { … … 159 194 return $dbh; 160 195 } 196 161 197 return; 162 198 } … … 182 218 183 219 The C<status_callback> gets called each time an entry in the 184 database is added, updated, or deleted by the C<update _db> and185 C<sync _db> methods. The arguments passed to the callback are220 database is added, updated, or deleted by the C<update> and 221 C<sync> methods. The arguments passed to the callback are 186 222 a status code (A, U, or D) and the filename for that entry. 187 223 The default callback just prints these to C<STDERR>: … … 224 260 $finder->create_db($db_filename); 225 261 226 Creates a SQLite database in the file named c<$db_filename>.262 Creates a SQLite database in the file named C<$db_filename>. 227 263 228 264 =cut … … 530 566 =head1 TODO 531 567 532 Database maintanence routines (e.g. clear out old entries) 533 534 Allow the passing of a DSN or an already created C<$dbh> instead 535 of a SQLite database filename; or write driver classes to handle 536 database dependent tasks (create_db/destroy_db). 568 Store/search ID3v2 tags 569 570 Driver classes to handle database dependent tasks? 537 571 538 572 =head1 SEE ALSO
Note: See TracChangeset
for help on using the changeset viewer.