diff options
Diffstat (limited to 'config-db/OpenSLX/MetaDB/SQLite.pm')
-rw-r--r-- | config-db/OpenSLX/MetaDB/SQLite.pm | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/config-db/OpenSLX/MetaDB/SQLite.pm b/config-db/OpenSLX/MetaDB/SQLite.pm index 558aebf9..c0725191 100644 --- a/config-db/OpenSLX/MetaDB/SQLite.pm +++ b/config-db/OpenSLX/MetaDB/SQLite.pm @@ -35,6 +35,27 @@ sub new return bless $self, $class; } +sub databaseExists +{ + my $self = shift; + + my $fullDBPath = $self->_getDBPath() . "/$openslxConfig{'db-name'}"; +print "$fullDBPath\n"; + return -e $fullDBPath; +} + +sub dropDatabase +{ + my $self = shift; + + if ($self->{dbh}) { + die "need to disconnect before you can drop the database!"; + } + + my $fullDBPath = $self->_getDBPath() . "/$openslxConfig{'db-name'}"; + system("rm -rf $fullDBPath") if -e $fullDBPath; +} + sub connect ## no critic (ProhibitBuiltinHomonyms) { my $self = shift; @@ -42,9 +63,7 @@ sub connect ## no critic (ProhibitBuiltinHomonyms) my $dbSpec = $openslxConfig{'db-spec'}; if (!defined $dbSpec) { # build $dbSpec from individual parameters: - my $dbBasepath = "$openslxConfig{'private-path'}/db"; - my $dbDatadir = 'sqlite'; - my $dbPath = "$dbBasepath/$dbDatadir"; + my $dbPath = $self->_getDBPath; system("mkdir -p $dbPath") unless -e $dbPath; $dbSpec = "dbname=$dbPath/$openslxConfig{'db-name'}"; } @@ -102,4 +121,11 @@ sub schemaAddColumns return; } +sub _getDBPath +{ + my $self = shift; + + return "$openslxConfig{'private-path'}/db/sqlite"; +} + 1; |