File Coverage

blib/lib/AutoSQL/DBSQL/DBIHarness.pm
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1             package AutoSQL::DBSQL::DBIHarness;
2 1     1   13074 use strict;
  1         2  
  1         28  
3 1     1   717 use AutoSQL::SQLGenerator;
  0            
  0            
4              
5             use AutoSQL::DBSQL::DBContext;
6             our @ISA=qw(AutoSQL::DBSQL::DBContext);
7              
8             sub create_db {
9             my $self=shift;
10             my ($dbh, $db_name)=$self->_dbh_dbname(@_);
11             my $sql="CREATE DATABASE $db_name";
12             $dbh->do("CREATE DATABASE $db_name");
13             $self->debug($sql);
14             $self->dbname($db_name);
15            
16             $self->db_handle($self->_db_locator);
17             }
18              
19             sub drop_db {
20             my $self=shift;
21             my ($dbh, $db_name)=$self->_dbh_dbname(@_);
22             my $sql="DROP DATABASE $db_name";
23             $dbh->do($sql);
24             $self->debug($sql);
25             }
26              
27             sub _dbh_dbname {
28             my $self=shift;
29             my $db_name=shift||$self->dbname;
30             my $dbh=$self->db_handle($self->_host_locator
31             # (defined $self->dbname)?$self->_db_locator:$self->_host_locator
32             );
33             return ($dbh, $db_name);
34             }
35              
36             sub import_tables {
37             my $self=shift;
38             my $schema=shift;
39             my @sql=AutoSQL::SQLGenerator->generate_table_sql($schema);
40             my $dbh =$self->db_handle();
41             foreach(@sql){
42             $dbh->do($_);
43             }
44             }
45              
46             1;
47              
48             __END__