File: DBConfig.pm

package info (click to toggle)
libtangram-perl 2.10-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 1,184 kB
  • ctags: 702
  • sloc: perl: 9,665; makefile: 9
file content (46 lines) | stat: -rw-r--r-- 1,009 bytes parent folder | download | duplicates (2)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46

package DBConfig;

use DBI;
use Tangram qw(:core :compat_quiet);
local $/;

my $config = $ENV{TANGRAM_CONFIG} || 't/CONFIG';

open CONFIG, "$config"
    or die "Cannot open $config, reason: $!";

my ($tx, $subsel, $ttype);
($cs, $user, $passwd, $tx, $subsel, $ttype)
    = split "\n", <CONFIG>;

if ($tx =~ m/(\d)/) {
    $no_tx = !$1;
}
if ($subsel =~ m/(\d)/) {
    $no_subselects = !$1;
}
if ($ttype =~ m/table_type\s*=\s*(.*)/) {
    $table_type = $1;
}

$vendor = (split ':', $cs)[1];;
$dialect = "Tangram::$vendor";  # deduce dialect from DBI driver
eval "use $dialect";
($dialect = 'Tangram::Relational'), eval("use $dialect") if $@;
print $Tangram::TRACE "Vendor driver $dialect not found - using ANSI SQL ($@)\n"
    if $@ and $Tangram::TRACE;
print $Tangram::TRACE "Using dialect $dialect\n" if $Tangram::TRACE;

our $AUTOLOAD;
sub AUTOLOAD {
    shift if UNIVERSAL::isa($_[0], __PACKAGE__);
    $AUTOLOAD =~ s{.*::}{};
    return $$AUTOLOAD;
}

sub cparm {
    return ($cs, $user, $passwd);
}

1;