]> mj.ucw.cz Git - pciids.git/blob - PciIds/Db.pm
ids_to_dbdump is still needed by the mailbot
[pciids.git] / PciIds / Db.pm
1 #       PciIds web database
2 #       Copyright (C) 2008 Michal Vaner (vorner@ucw.cz)
3 #
4 #       This program is free software; you can redistribute it and/or modify
5 #       it under the terms of the GNU General Public License as published by
6 #       he Free Software Foundation; either version 2 of the License, or
7 #       (at your option) any later version.
8 #
9 #       This program is distributed in the hope that it will be useful,
10 #       but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #
13 #       GNU General Public License for more details.
14 #
15 #       You should have received a copy of the GNU General Public License
16 #       along with this program; if not, write to the Free Software
17 #       Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19 package PciIds::Db;
20 use strict;
21 use warnings;
22 use base 'Exporter';
23 use PciIds::Config;
24 use DBI;
25
26 our @EXPORT = qw( &connectDb );
27
28 sub connectDb() {
29         my ( $uri, $user, $passwd ) = confList( [ "dburi", "dbuser", "dbpasswd" ] );
30         my $result = DBI->connect( $uri, $user, $passwd, { 'AutoCommit' => 0, 'RaiseError' => 1, 'PrintError' => 0 } ) or die "Could not connect to database $uri (".DBI->errstr.")\n";
31 }
32
33 checkConf( [ "dbuser", "dbpasswd" ] );
34 defConf( { "dbname" => "pciids" } );
35 defConf( { "dburi" => "dbi:mysql:".$config{"dbname"} } );
36
37 return 1;