summaryrefslogtreecommitdiffstats
path: root/config-db/OpenSLX/MetaDB/SQLite.pm
diff options
context:
space:
mode:
authorOliver Tappe2007-11-09 16:54:04 +0100
committerOliver Tappe2007-11-09 16:54:04 +0100
commitbf6beb5f4374938b20af65af76003376d9ea0ffd (patch)
tree256ba47b2976b0782317112d99fd0ee3c67312ae /config-db/OpenSLX/MetaDB/SQLite.pm
parent* added default debconf database for openslx systems based on (diff)
downloadcore-bf6beb5f4374938b20af65af76003376d9ea0ffd.tar.gz
core-bf6beb5f4374938b20af65af76003376d9ea0ffd.tar.xz
core-bf6beb5f4374938b20af65af76003376d9ea0ffd.zip
* started to work on configDB-tests
git-svn-id: http://svn.openslx.org/svn/openslx/trunk@1407 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'config-db/OpenSLX/MetaDB/SQLite.pm')
-rw-r--r--config-db/OpenSLX/MetaDB/SQLite.pm32
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;