2 |
## $Id$ |
## $Id$ |
3 |
## -------------------------------------------------------------------------------- |
## -------------------------------------------------------------------------------- |
4 |
## $Log$ |
## $Log$ |
5 |
|
## Revision 1.2 2002/07/20 11:09:58 cvsjoko |
6 |
|
## + bugfixes |
7 |
|
## + dont' print sql-errors |
8 |
|
## |
9 |
## Revision 1.1 2002/07/19 18:14:03 cvsjoko |
## Revision 1.1 2002/07/19 18:14:03 cvsjoko |
10 |
## no message |
## no message |
11 |
## |
## |
109 |
croak "please supply a dsn or a \"dbmeta\"-hash" if (!$dbmeta); |
croak "please supply a dsn or a \"dbmeta\"-hash" if (!$dbmeta); |
110 |
$dbmeta = patch_dbmeta($dbmeta); |
$dbmeta = patch_dbmeta($dbmeta); |
111 |
if (!$dbmeta->{connected}) { |
if (!$dbmeta->{connected}) { |
112 |
if ($dbmeta->{dbh} = DBI->connect($dbmeta->{dsn})) { |
if ($dbmeta->{dbh} = DBI->connect($dbmeta->{dsn}, '', '', { PrintError => 0 } )) { |
113 |
$dbmeta->{dbh}->trace($dbmeta->{trace_level}, $dbmeta->{trace_file}); |
$dbmeta->{dbh}->trace($dbmeta->{trace_level}, $dbmeta->{trace_file}); |
114 |
$dbmeta->{dbh}->{PrintError} = 0; |
$dbmeta->{dbh}->{PrintError} = 0; |
115 |
$dbmeta->{connected} = 1; |
$dbmeta->{connected} = 1; |
116 |
$dbmeta_ref_cache = $dbmeta; |
$dbmeta_ref_cache = $dbmeta; |
117 |
|
return 1; |
118 |
} |
} |
119 |
} |
} |
120 |
} |
} |
170 |
trace_level => 1, |
trace_level => 1, |
171 |
trace_file => 'dbitrace', |
trace_file => 'dbitrace', |
172 |
}; |
}; |
173 |
connectTarget($dbmeta); |
my $bool_ok; |
174 |
sendSql($sql); |
if (connectTarget($dbmeta)) { |
175 |
disconnectTarget($dbmeta); |
sendSql($sql); |
176 |
|
#print "state: ", $dbmeta->{dbh}->errstr, "\n"; |
177 |
|
$bool_ok = ($dbmeta->{dbh} && $dbmeta->{dbh}->state && !$dbmeta->{dbh}->err); |
178 |
|
disconnectTarget($dbmeta); |
179 |
|
} |
180 |
|
return $bool_ok; |
181 |
} |
} |
182 |
|
|
183 |
sub createSqlDb { |
sub createSqlDb { |
184 |
my $dsn = shift; |
my $dsn = shift; |
185 |
my $dbname = getDbNameByDsn($dsn); |
my $dbname = getDbNameByDsn($dsn); |
186 |
print " - creating database $dbname", "\n"; |
print " - creating rdbms-database $dbname ($dsn) ..."; |
187 |
my $sql; |
my $sql; |
188 |
$sql = "CREATE DATABASE $dbname;"; |
$sql = "CREATE DATABASE $dbname;"; |
189 |
sqlDbAction($dsn, $sql); |
if ( sqlDbAction($dsn, $sql) ) { |
190 |
|
print "ok"; |
191 |
|
} else { |
192 |
|
print "failed"; |
193 |
|
} |
194 |
|
print "\n"; |
195 |
} |
} |
196 |
|
|
197 |
sub dropSqlDb { |
sub dropSqlDb { |
198 |
my $dsn = shift; |
my $dsn = shift; |
199 |
my $dbname = getDbNameByDsn($dsn); |
my $dbname = getDbNameByDsn($dsn); |