summaryrefslogtreecommitdiffstats
path: root/bin/create_genre
blob: c9687e7bcf4eec44687604f8a5735aa99940d3eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl

# Copyright (c) 2000 Kveton.com
# All rights reserved.

# $Id: create_genre,v 1.2 2003/11/24 05:53:12 vollmerk Exp $
# $Source: /data/cvsroot/ampache/bin/create_genre,v $

# Create the genres in the database for ease of use

use DBI;

# User, pass and database names
my $user = '_user_';
my $pass = '_password_';
my $db_name = 'ampache';
my $db_host = 'localhost';

$dbh = DBI->connect("dbi:mysql:database=$db_name;host=$db_host;port=3306", $user, $pass);
my $sql = qq{INSERT INTO genre (id,name) VALUES (?,?)};
my $sth = $dbh->prepare($sql);

open(GENRE, "< genres.txt");

while ( $line = <GENRE> ) {
  chomp $line;
  my ($id, $name) = split(/\./, $line);
  print "$id : $name\n";
  $sth->execute($id,$name);
}

1;